# README
SLOG - Simple Log for GO
Slog uses logrus and lumberjack to provide a simple logging interface with two main funcs:
Infof(string, ...interface{})
and Errorf(string, ...interface{})
for logging to stdout and logfile at the same time. It also supports executing hooks.
Log messages are auto-truncated in case of big data structures accidentally filling up logs.
Features
- Output to file and stdout at the same time
- Truncate long error messages
- Levels (Info, Error, Fatal)
- Hooks (to send incoming messages to any other system)
Usage
package main
import "github.com/apioapp/slog"
func main() {
a := map[string]string{"A":"b"}
slog.RegisterHook(func(message string) error{
// Send to Grafana
},slog.ErrorLog)
slog.Errorf("%v",a)
}
# Functions
Close will close the logfile.
Errorf logs to dashboard (sends message through log channel) plus echoes to standard output.
Fatalf logs to dashboard (sends message through log channel) plus echoes to standard output.
Infof logs to dashboard (sends message through log channel) plus echoes to standard output.
No description provided by the author
RegisterHook will execute given hook function on every message.
RegisterLevelHook will execute given hook function on every message (message and level).
SetFilename modifies the output file path.
SetOutput sets the standard logger output to a writer.
# Variables
No description provided by the author
# Type aliases
HookFunc is a callback function type, getting message as argument.
LevelHookFunc is hook func with log level input attribute.