Documentation
¶
Overview ¶
Package logger : The logger package contains the implementation of log handling.
Example (Logger) ¶
This example show the following: - Discard Trace messages - Write Info messages to stdout - Write Warning to stdout and log file - Write Error to stderr and log file
package main import ( "io" "io/ioutil" "log" "os" logger "github.com/ibm-security-innovation/libsecurity-go/logger" ) func main() { fileName := "log-file.txt" os.Remove(fileName) file, err := os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { log.Fatalln("Failed to open log file", fileName, ":", err) } multiW := io.MultiWriter(file, os.Stdout) multiE := io.MultiWriter(file, os.Stderr) logger.Init(ioutil.Discard, os.Stdout, multiW, multiE) logger.Trace.Println("Example: I have something standard to say") logger.Info.Println("Example: Special Information") logger.Warning.Println("Example: There is something you need to know about") logger.Error.Println("Example: Something has failed") }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Trace : write trace information to the logger Trace *log.Logger // Info : write info and trace information to the logger Info *log.Logger // Warning : write warnings, info and trace information to the logger Warning *log.Logger // Error : write errors, warnings, info and trace information to the logger Error *log.Logger )
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.