Beispiel #1
0
func init() {
	var err error

	// setup logger
	stderr, err = logger.New("stderr")
	if err != nil {
		panic(err.Error())
	}

	stderr.SetLevelByName("info")
	stderr.SetFlag(log.Lshortfile)
}
Beispiel #2
0
func NewAppLogger(output, filename string) *AppLogger {
	switch output {
	case "stdout", "stderr", "null", "nil":
		// skip
	default:
		if output[0] != '/' {
			output = path.Join(output, filename+".log")
		}
	}

	l, err := logger.New(output)
	if err != nil {
		log.Println("Cannot create logger:", err)

		return nil
	}

	return &AppLogger{l, ""}
}
Beispiel #3
0
func NewAppLogger(output, filename string) *AppLogger {
	switch output {
	case "stdout", "stderr", "null", "nil":
		// skip

	default:
		if output[0] != '/' {
			output = path.Join(output, filename+".log")
		}
	}

	l, err := logger.New(output)
	if err != nil {
		log.Printf("logger.New(%s): %v\n", output, err)

		return nil
	}

	logger := &AppLogger{l, ""}
	return logger
}