Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( Llongfile = 1 << iota Lshortfile Ltime Llevel LstdFlags = Ltime | Lshortfile | Llevel )
flags
Variables ¶
This section is empty.
Functions ¶
func NewConsoleLogger ¶
NewConsoleLogger create new Logger with ConsoleLogFormatter
func StackLogLevel ¶
StackLogLevel temporary change log level and return recover function
Example ¶
package main import ( "fmt" "os" "github.com/sirupsen/logrus" "github.com/tsaikd/KDGoLib/logrusutil" ) func main() { // logger := logrus.New() logger := &logrus.Logger{ Out: os.Stdout, Formatter: &logrusutil.ConsoleLogFormatter{ Flag: logrusutil.Llevel, }, Hooks: make(logrus.LevelHooks), Level: logrus.InfoLevel, } defer func() { fmt.Println("after logger level", logger.Level) }() logger.Debugln("debug message") logger.Infoln("info message") defer logrusutil.StackLogLevel(logger, logrus.DebugLevel)() fmt.Println("stack logger level", logger.Level) logger.Debugln("debug message") logger.Infoln("info message") }
Output: [info] info message stack logger level debug [debug] debug message [info] info message after logger level info
Types ¶
type ConsoleLogFormatter ¶
type ConsoleLogFormatter struct { TimestampFormat string Flag int CallerOffset int RuntimeCallerFilters []runtimecaller.Filter }
ConsoleLogFormatter suitable formatter for console
Click to show internal directories.
Click to hide internal directories.