// NewCallSiteFileLogger returns a fully configured Sender
// implementation that writes log messages to a specified file in a
// format that includes the filename and line number of the call site
// of the logger.
773766
func NewCallSiteFileLogger(name, fileName string, depth int, l LevelInfo) (Sender, error) {
	s, err := MakeCallSiteFileLogger(fileName, depth)
	if err != nil {
		return nil, err
	}

	return setup(s, name, l)
}
765944
func NewRotateLogger(f string, maxLines, maxRotate int) (*FileLogger, error) {
	return NewFileLogger(f, INFO, ROTATE, maxLines, maxRotate, BUFSIZE)
}
1193746
func NewLogger(w io.Writer) Logger {
	l := logrus.New()
	l.Out = w
	return logger{entry: logrus.NewEntry(l)}
}
967430
func NewFileLogConfig(rotate bool, maxSize uint) FileLogConfig {
	return FileLogConfig{FileLogConfig: zaplog.FileLogConfig{
		LogRotate: rotate,
		MaxSize:   int(maxSize),
	},
	}
}
679964
func MakeJSONFileLogger(file string) (Sender, error) {
	s, err := MakePlainFileLogger(file)
	if err != nil {
		return nil, err
	}

	if err = s.SetFormatter(MakeJSONFormatter()); err != nil {
		return nil, err
	}

	return s, nil
}
536453
func NewLogger() *Logger {
	logger := &Logger{*log.New(os.Stdout, "", log.LstdFlags), false, false}
	return logger
}
485371
func NewFileRotator(path string, baseFile string, maxFiles int,
	fileSize int64, logger hclog.Logger) (*FileRotator, error) {
	logger = logger.Named("rotator")
	rotator := &FileRotator{
		MaxFiles: maxFiles,
		FileSize: fileSize,

		path:         path,
		baseFileName: baseFile,

		flushTicker: time.NewTicker(bufferFlushDuration),
		logger:      logger,
		purgeCh:     make(chan struct{}, 1),
		doneCh:      make(chan struct{}, 1),
	}

	if err := rotator.lastFile(); err != nil {
		return nil, err
	}
	go rotator.purgeOldFiles()
	go rotator.flushPeriodically()
	return rotator, nil
}
1292107
func newLogger(w zapcore.WriteSyncer) *zap.Logger {
	conf := Config()
	enc := zapcore.NewConsoleEncoder(conf)
	core := zapcore.NewCore(enc, w, Level)

	return zap.New(core)
}
582856
func MakeCallSiteConsoleLogger(depth int) Sender {
	s := MakeNative()
	_ = s.SetFormatter(MakeCallSiteFormatter(depth))

	return s
}
960008
func NewBackupLogger(f string, maxBackup int) (*FileLogger, error) {
	return NewFileLogger(f, INFO, BACKUP, 0, maxBackup, BUFSIZE)
}
729295
func NewLogger() *Logger {
	l := &Logger{}
	l.base.SetPrefix("")
	l.base.SetFlags(log.Lmicroseconds | log.Lshortfile)
	l.SetLevel(LDebug, LInfo, LWarn, LError, LFatal)
	l.SetWriter(os.Stderr)
	return l
}
614714
func NewLogHelper(v ...interface{}) (*LogHelper, error) {
	mask := os.O_APPEND | os.O_RDWR | os.O_CREATE
	mylog := LogHelper{}

	// use stdout & stderr
	if len(v) == 0 {
		mylog.Logger[0] = log.New(os.Stdout, "TRACE - ", FLAGS)
		mylog.Logger[1] = log.New(os.Stderr, "ERROR - ", FLAGS)
		return &mylog, nil
	}
	fileName := v[0].(string)
	// app.log & app.log.error
	mylog.LogFileNames = [2]string{fileName, fileName + ".error"}
	// check dir wether exist and mkdir
	if _, err := os.Stat(path.Dir(mylog.LogFileNames[0])); err != nil {
		os.Mkdir(path.Dir(mylog.LogFileNames[0]), 0777)
	}

	if logFile, err := os.OpenFile(mylog.LogFileNames[0], mask, 0666); err == nil {
		mylog.Logger[0] = log.New(logFile, "TRACE - ", FLAGS)
		mylog.Logger[0].Flags()
	} else {
		return nil, err
	}

	if logFile, err := os.OpenFile(mylog.LogFileNames[1], mask, 0666); err == nil {
		mylog.Logger[1] = log.New(logFile, "ERROR - ", FLAGS)
	} else {
		return nil, err
	}
	return &mylog, nil
}
331566
func NewLogger(writer io.Writer, fields ...Field) Logger {
	return &writerLogger{writer, Fields(fields)}
}
305690
func NewFileLogger(f string, o, mode, maxLines, maxRotate, bufsize int) (*FileLogger, error) {
	var file *os.File
	var err error

	switch mode {
	case APPEND:
		// open log file, append if it already exists
		file, err = os.OpenFile(f, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
	case TRUNC:
		// just truncate file and start logging
		file, err = os.OpenFile(f, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
	case BACKUP:
		// rotate every time a new logger is created
		file, err = openBackup(f, 0, maxRotate)
	case ROTATE:
		// "normal" rotation, when file reaches line limit
		file, err = openBackup(f, maxLines, maxRotate)
	default:
		return nil, fmt.Errorf("Invalid mode parameter: %d", mode)
	}
	if err != nil {
		return nil, fmt.Errorf("Error creating logger: %s", err)
	}

	return newFileLogger(file, o, mode, maxLines, maxRotate, bufsize), nil
}
1130379
func NewLogWatcher() *LogWatcher {
	return &LogWatcher{
		Msg:          make(chan *Message, logWatcherBufferSize),
		Err:          make(chan error, 1),
		producerGone: make(chan struct{}),
		consumerGone: make(chan struct{}),
	}
}
16971
func NewPlainLogger(name string, l LevelInfo) (Sender, error) {
	return setup(MakePlainLogger(), name, l)
}
1313329
func NewErrorLogger(name string, l LevelInfo) (Sender, error) {
	return setup(MakeErrorLogger(), name, l)
}