Categorygithub.com/codemodify/systemkit-logging
modulepackage
1.9.3
Repository: https://github.com/codemodify/systemkit-logging.git
Documentation: pkg.go.dev

# 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.

PIPEFormattersPersisters
DATALogEntrySimpleFile

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.

PIPEFormattersMixersPersisters
DATALogEntrySimpleMultiConsole, 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.

PIPEPipeMixersPipesFormattersPersisters
DATALogEntryPipe-0MultiPipe-1, Pipe-2Simple, AWSFile, AWS

API

LogEntry

 FunctionalityCode Base
Test & ExamplesTest and Examplesgithub.com/codemodify/systemkit-logging-tests
RFC 3339 NanoFormats the log as RFC 3339github.com/codemodify/systemkit-logging-formatters-timerfc3339nano
FileLogs to filegithub.com/codemodify/systemkit-logging-persisters-file
ConsoleLogs to consolegithub.com/codemodify/systemkit-logging-persisters-console
Console + ColorsLogs to console with colorsgithub.com/codemodify/systemkit-logging-persisters-consolewithcolors
MultiLogs to multiple loggers at oncegithub.com/codemodify/systemkit-logging-mixers-multi
AsyncCalls a logger without blockinggithub.com/codemodify/systemkit-logging-mixers-async
BufferedBuffers the log as configuredgithub.com/codemodify/systemkit-logging-mixers-buffered
Windows Event LogLogs to Windows Event Loggithub.com/codemodify/systemkit-logging-persisters-windowseventlog
WithFieldsDecorates / adds additional logging syntax "..WithFields()"github.com/codemodify/systemkit-logging-extenders-withfields
AdvancedAdvanced logging techniques for complex concurrencygithub.com/codemodify/systemkit-logging-advanced

Remarks

  • Default is emptyLogger{}
    • it is initialized in init() of the package github.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,
      	}
      }
      

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Add shortcuts + duplicate `Logger`.
NewEmptyLogger - returns a logger that does nothing.
NewLoggerImplementation -.
NewPipe - returns a pipe.
NewStderrLogger - logs to STDERR.
NewStdoutLogger - logs to STDOUT.
No description provided by the author
No description provided by the author
SetLogger -.
No description provided by the author
No description provided by the author
Add shortcuts + duplicate `Logger`.
Add shortcuts with formats + duplicate `Logger`.
No description provided by the author
No description provided by the author

# Constants

# Structs

LogEntry -.

# Interfaces

CoreLogger -.
Logger -.

# Type aliases

LogType - Log type.