Documentation
¶
Overview ¶
Package logger implements logging methods with formatted output and more detailed logging information than provided in the standard logging package of golang. It is possible to specify the level of logging information to be written as output (Default: all information is written). Use the `*log.Logger` variables and chain them to common I/O writers for printing logging information.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Debug = getDebugLogger()
var Error = getErrorLogger()
var Info = getInfoLogger()
var Warning = getWarningLogger()
Functions ¶
func SetLevel ¶
func SetLevel(level LogLevel)
SetLevel sets the level of logging information written as output.
Example ¶
package main import ( "github.com/coneno/logger" ) func main() { logger.SetLevel(logger.LEVEL_DEBUG) logger.Error.Printf("error") logger.Warning.Printf("warning") logger.Debug.Printf("debug") logger.Info.Printf("info") }
Output:
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel indicates the level of logging information passed as argument to SetLevel function.
There are four possible values for type `LogLevel`:
1. `LEVEL_ERROR`: Only Error logs are written to `stderr`.
2. `LEVEL_WARNING`: Warnings and errors are written to `stderr`.
3. `LEVEL_INFO`: Errors and warnings are written to `stderr`, infos to `stdout`.
4. `LEVEL_DEBUG`: Errors and warnings are written to `stderr`, infos and debugs to `stdout`.