// NewJSONLogger creates a new JSON logger
493140
func NewJSONLogger(w io.Writer, ErrHandler ErrorHandler) Logger {
	if w == ioutil.Discard {
		return Discard
	}
	return &ErrorLogLogger{
		RootLogger: &JSONLogger{
			Out:             w,
			MissingValueKey: Msg,
		},
		ErrHandler: ErrHandler,
	}
}
625467
func NewLogger() *Logger {
	logger := &coreLogger{
		ErrorWriter: os.Stderr,
		BufferSize:  1024,
		MaxLevel:    LevelDebug,
		Targets:     make([]Target, 0),
	}
	return &Logger{logger, "app", DefaultFormatter}
}
535411
func NewLoggingService(logger log.Logger, s Service) Service {
	return &loggingService{logger, s}
}
1174990
func New() *Logger {
	defaultOutputMutex.RLock()
	defer defaultOutputMutex.RUnlock()

	logger := &Logger{
		Fields:  make(map[string]interface{}),
		outputs: make([]*loggerOutputWrapper, len(defaultOutputs)),
	}
	copy(logger.outputs, defaultOutputs)

	return logger
}
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
}
447201
func NewLoggerFromLoggingConfig(loggingConfig *logconfig.LoggingConfig) (*logging.Logger, error) {
	if loggingConfig == nil {
		return NewStdErrLogger()
	} else {
		outputLogger, errCh, err := loggerFromLoggingConfig(loggingConfig)
		if err != nil {
			return nil, err
		}
		logger := logging.NewLogger(outputLogger)
		if !loggingConfig.Trace {
			logger.Trace = log.NewNopLogger()
		}
		go func() {
			err := <-errCh.Out()
			if err != nil {
				fmt.Printf("Logging error: %v", err)
			}
		}()
		return logger, nil
	}
}
748537
func New(opts ...OptFunc) *Logger {
	l := &Logger{lg: log.New(os.Stderr, "", LstdFlags&maskStdLogFlags), flag: LstdFlags, min: TRACE}
	for _, opt := range opts {
		opt(l)
	}
	return l
}
810616
func NewLogger(config Config) (Logger, error) {
	switch config.Name {
	case Console:
		return NewConsoleLogger(config)
	case Syslog:
		return NewSysLogger(config)
	case UDPLog:
		return NewUDPLogger(config)
	}
	return nil, fmt.Errorf("unknown logger: %v", config)
}
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
}
1313329
func NewErrorLogger(name string, l LevelInfo) (Sender, error) {
	return setup(MakeErrorLogger(), name, l)
}
841544
func New(wr io.Writer) *Logger {
	return &Logger{
		wr:    wr,
		level: logLevelNotice,
		pid:   os.Getpid(),
		tty:   istty(wr),
		app:   'M',
	}
}
354339
func NewLogger(f *Fibre) *Logger {

	return &Logger{&logrus.Logger{
		Out:       os.Stderr,
		Level:     logrus.ErrorLevel,
		Hooks:     make(logrus.LevelHooks),
		Formatter: new(logrus.TextFormatter),
	}}

}
1273592
func NewParser(config *Config) (Parser, error) {
	var err error
	var parser Parser
	switch config.DataFormat {
	case "json":
		parser = newJSONParser(config.MetricName,
			config.TagKeys,
			config.JSONNameKey,
			config.JSONStringFields,
			config.JSONQuery,
			config.JSONTimeKey,
			config.JSONTimeFormat,
			config.JSONTimezone,
			config.DefaultTags)
	case "value":
		parser, err = NewValueParser(config.MetricName,
			config.DataType, config.DefaultTags)
	case "influx":
		parser, err = NewInfluxParser()
	case "nagios":
		parser, err = NewNagiosParser()
	case "graphite":
		parser, err = NewGraphiteParser(config.Separator,
			config.Templates, config.DefaultTags)
	case "collectd":
		parser, err = NewCollectdParser(config.CollectdAuthFile,
			config.CollectdSecurityLevel, config.CollectdTypesDB, config.CollectdSplit)
	case "dropwizard":
		parser, err = NewDropwizardParser(
			config.DropwizardMetricRegistryPath,
			config.DropwizardTimePath,
			config.DropwizardTimeFormat,
			config.DropwizardTagsPath,
			config.DropwizardTagPathsMap,
			config.DefaultTags,
			config.Separator,
			config.Templates)
	case "wavefront":
		parser, err = NewWavefrontParser(config.DefaultTags)
	case "grok":
		parser, err = newGrokParser(
			config.MetricName,
			config.GrokPatterns,
			config.GrokNamedPatterns,
			config.GrokCustomPatterns,
			config.GrokCustomPatternFiles,
			config.GrokTimezone,
			config.GrokUniqueTimestamp)
	case "csv":
		parser, err = newCSVParser(config.MetricName,
			config.CSVHeaderRowCount,
			config.CSVSkipRows,
			config.CSVSkipColumns,
			config.CSVDelimiter,
			config.CSVComment,
			config.CSVTrimSpace,
			config.CSVColumnNames,
			config.CSVColumnTypes,
			config.CSVTagColumns,
			config.CSVMeasurementColumn,
			config.CSVTimestampColumn,
			config.CSVTimestampFormat,
			config.DefaultTags)
	case "logfmt":
		parser, err = NewLogFmtParser(config.MetricName, config.DefaultTags)
	default:
		err = fmt.Errorf("Invalid data format: %s", config.DataFormat)
	}
	return parser, err
}
643940
func newLogger(name string) (Logger, func(Level)) {
	logger := logging.NewLogger(name)
	logger.SetLevel(convertLevel(getLogLevel()))

	if os.Getenv("KITE_LOG_NOCOLOR") != "" {
		logging.StdoutHandler.Colorize = false
		logging.StderrHandler.Colorize = false
	}

	setLevel := func(l Level) {
		logger.SetLevel(convertLevel(l))
		logging.DefaultHandler.SetLevel(convertLevel(l))
	}

	return logger, setLevel
}
943567
func NewLogger(sink io.Writer, options ...Option) *Logger {
	if sink == nil {
		sink = ioutil.Discard
	}

	l := &Logger{
		sink:     sink,
		throttle: DefaultLoggingThrottle,
		widthFn: func() int {
			size, err := ts.GetSize()
			if err != nil {
				return 80
			}
			return size.Col()
		},
		queue: make(chan Task),
		tasks: make(chan Task),
		wg:    new(sync.WaitGroup),
	}

	for _, option := range options {
		option(l)
	}

	l.tty = tty(sink)

	go l.consume()

	return l
}
163529
func NewLogger(component string) *TestLogger {
	buf := gbytes.NewBuffer()
	log := lager.NewLogger(component)
	log.RegisterSink(lager.NewWriterSink(buf, lager.DEBUG))
	return &TestLogger{log, buf}
}
451973
func NewLogger(channellen int64, stealLevel ...int) *BeeLogger {
	bl := new(BeeLogger)
	bl.level = LevelDebug
	bl.loggerFuncCallDepth = 2
	bl.msg = make(chan *logMsg, channellen)
	bl.outputs = make(map[string]LoggerInterface)
	bl.status = WORK
	bl.steal = make(chan *logMsg, channellen)
	if len(stealLevel) > 0 {
		bl.stealLevelPreset = stealLevel[0]
	} else {
		bl.stealLevelPreset = LevelNothing
	}
	return bl
}