# README
Logging
The missing robust, flexible, complete and advanced logging framework for Go
Check https://github.com/codemodify/systemkit-logging-tests
to see usages of basic, intermediary and advanced with concurrency
How It Works
The concept is as follows:
LogEntry
is logged and sent into a pipe- Each block in the transformation pipe may apply a transformation to the
LogEntry
and pass it along
Example A: consider the defined pipe below form left to right
What happens is that a LogEntry
is sent to the first transformer
in the pipe that will format the log message,
then the next one will save it to a file.
PIPE | Formatters | Persisters | |
---|---|---|---|
DATA | LogEntry | Simple | File |
Example B: consider the defined pipe below form left to right
What happens is that a LogEntry
is sent to the first transformer
in the pipe that will format the log message,
then the next one will send it to an array of persisters, one will save to file and the other one will display in
the console.
PIPE | Formatters | Mixers | Persisters | |
---|---|---|---|---|
DATA | LogEntry | Simple | Multi | Console , File |
Example C: consider the defined pipe below form left to right
What happens is that a LogEntry
is sent to the first transformer
in the pipe that will send the same LogEntry
,
to multiple "loggers" each having their own transformation pipes.
Pipe-1
will format the log entry using one formatter and then save it to a file.
Pipe-2
will format the log entry using a different formatter and then send it to aws storage.
PIPE | Pipe | Mixers | Pipes | Formatters | Persisters | |
---|---|---|---|---|---|---|
DATA | LogEntry | Pipe-0 | Multi | Pipe-1 , Pipe-2 | Simple , AWS | File , AWS |
API
Remarks
- Default is
emptyLogger{}
- it is initialized in
init()
of the packagegithub.com/codemodify/systemkit-logging
- the reasoning is to enable easy adoption when writing components with conditional logging
- consider the code differences of the blocks ONE and TWO below, ONE allows for a lot less noise
- ONE
import github.com/codemodify/systemkit-logging type A struct {} func (thisRef A) Compute { logging.Debug("log line") } func NewA() *A { return &A{} }
- TWO
import github.com/codemodify/systemkit-logging type A struct { logger logging.Logger } func (thisRef A) Compute { if logger.logger != { thisRef.logging.Debug("log line") } } func NewA(logger logging.Logger) *A { return &A{ logger: logger, } }
- it is initialized in