Exemple #1
0
func Example() {
	logger := sawmill.NewLogger()
	defer logger.Stop()

	writer, err := writer.New(os.Stdout, formatter.SIMPLE_FORMAT)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	handler := filter.New(writer).LevelMin(sawmill.NoticeLevel)
	logger.AddHandler("stdout", handler)

	logger.Debug("This is a debug message")
	logger.Error("This is an error message")

	// Output: This is an error message --
}
Exemple #2
0
// FilterHandler is a convience wrapper for filter.New().
//
// Example usage:
//  stdStreamsHandler := logger.GetHandler("stdStreams")
//  stdStreamsHandler = logger.FilterHandler(stdStreamsHandler).LevelMin(sawmill.ErrorLevel)
//  logger.AddHandler("stdStreams", stdStreamsHandler)
func (logger *Logger) FilterHandler(handler Handler, filterFuncs ...filter.FilterFunc) *filter.FilterHandler {
	return filter.New(handler, filterFuncs...)
}