예제 #1
0
파일: log.go 프로젝트: christianbak/sawmill
func New(out io.Writer, prefix string, flag int) *Logger {
	sml := sm.NewLogger()

	handler, _ := writer.New(out, formatter.CONSOLE_NOCOLOR_FORMAT)

	sml.AddHandler("logwriter", handler)

	return &Logger{sml: sml, prefix: prefix}
}
예제 #2
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 --
}