Example #1
0
File: init.go Project: dolab/gogo
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)
}
Example #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, ""}
}
Example #3
0
File: logger.go Project: dolab/gogo
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
}