// MakeStreamLogger constructs an unconfigured stream sender that
// writes un-formatted log messages to the specified io.Writer, or
// instance that implements a conforming subset.
183717
func MakeStreamLogger(ws WriteStringer) Sender {
	s := &streamLogger{
		fobj: ws,
		Base: NewBase(""),
	}

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	_ = s.SetErrorHandler(ErrorHandlerFromLogger(fallback))

	s.reset = func() {
		fallback.SetPrefix(fmt.Sprintf("[%s] ", s.Name()))
	}

	return s
}
64488
func (cfg Configuration) BuildLogger() (Logger, error) {
	writer := io.Writer(os.Stdout)

	if cfg.File != "" {
		fd, err := os.OpenFile(cfg.File, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
		if err != nil {
			return nil, err
		}

		writer = io.MultiWriter(writer, fd)
	}

	logger := NewLogger(writer)

	if len(cfg.Level) != 0 {
		level, err := ParseLevel(cfg.Level)
		if err != nil {
			return nil, err
		}

		logger = NewLevelLogger(logger, level)
	}

	if len(cfg.Fields) != 0 {
		var fields []Field
		for k, v := range cfg.Fields {
			fields = append(fields, NewField(k, v))
		}
		logger = logger.WithFields(fields...)
	}

	return logger, nil
}
1276017
func MakePlainLogger() Sender {
	s := &nativeLogger{
		Base: NewBase(""),
	}
	_ = s.SetFormatter(MakePlainFormatter())

	s.level = LevelInfo{level.Trace, level.Trace}

	s.reset = func() {
		s.logger = log.New(os.Stdout, "", 0)
		_ = s.SetErrorHandler(ErrorHandlerFromLogger(s.logger))
	}

	return s
}
1159290
func createLogger(name string, level Level, format string, timeFormat string, out io.Writer, sync bool) (*Logger, error) {
	return createCustomizedLogger(name, level, format, timeFormat, out, sync, DefaultQueueSize, DefaultRequestSize, DefaultBufferSize, DefaultTimeInterval)
}
1089396
func (memR *MempoolReactor) SetLogger(l log.Logger) {
	memR.Logger = l
	memR.Mempool.SetLogger(l)
}
424755
func NewProxyWriterWithLogger(w http.ResponseWriter, l *log.Logger) *ProxyWriter {
	return &ProxyWriter{
		w:   w,
		log: l,
	}
}
1203676
func (l *intLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger {
	if opts == nil {
		opts = &StandardLoggerOptions{}
	}

	return log.New(l.StandardWriter(opts), "", 0)
}
1034935
func createCustomizedLogger(name string, level Level, format string, timeFormat string, out io.Writer, sync bool, queueSize int, requestSize int, bufferSize int, timeInterval time.Duration) (*Logger, error) {
	logger := new(Logger)

	err := logger.parseFormat(format)
	if err != nil {
		return nil, err
	}

	// assign values to logger
	logger.name = name
	logger.level = level
	logger.out = out
	logger.seqid = 0
	logger.sync = sync
	logger.queue = make(chan string, queueSize)
	logger.request = make(chan request, requestSize)
	logger.flush = make(chan bool)
	logger.finish = make(chan bool)
	logger.quit = make(chan bool)
	logger.startTime = time.Now()
	logger.fd = nil
	logger.timeFormat = timeFormat
	logger.bufferSize = bufferSize
	logger.timeInterval = timeInterval

	// start watcher to write logs if it is async or no runtime field
	if !logger.sync {
		go logger.watcher()
	}

	return logger, nil
}
1263158
func (e *Crypter) MakePipe(out io.Writer) (io.Writer, error) {
	if e.used == true {
		return nil, errors.New("whatwhat: crypter was used twice")
	}

	// we only use Crypter once, its ok to have a zero IV
	var iv [aes.BlockSize]byte
	stream := cipher.NewCTR(e.block, iv[:])

	e.used = true

	return &cipher.StreamWriter{S: stream, W: out}, nil
}
1350711
func SimpleLogger(name string) (*Logger, error) {
	return createLogger(name, WARNING, BasicFormat, DefaultTimeFormat, os.Stdout, false)
}
1328112
func CreateLogger(args ...interface{}) (Logger, error) {
	config := Config{}
	logger := Logger{}
	r := regexp.MustCompile(`bunyan.Config$`)

	if len(args) == 0 {
		return logger, fmt.Errorf("Create logger requires either a bunyan.Config or String argument")
	}

	// get hostname
	if hostname, err := os.Hostname(); err != nil {
		return logger, err
	} else {
		logger.hostname = hostname
	}

	arg := args[0]
	argType := typeName(arg)

	if argType == "string" {
		config.Name = arg.(string)
	} else if r.MatchString(argType) {
		config = arg.(Config)
		if config.Name == "" {
			return logger, fmt.Errorf("Bunyan Config requires a name, none specified")
		}
	} else {
		return logger, fmt.Errorf("Create logger requires either a bunyan.Config or String argument")
	}

	// add the config to the logger
	logger.config = config
	logger.staticFields = config.StaticFields
	logger.serializers = config.Serializers

	// add the streams
	if len(config.Streams) != 0 {
		for _, stream := range config.Streams {
			logger.AddStream(stream)
		}
	} else if config.Stream != nil {
		simpleStream := Stream{Stream: config.Stream, Name: config.Name}
		logger.AddStream(simpleStream)
	}

	return logger, nil
}
1162424
func NewLogger() *Logger {
	logger := &Logger{ALogger: log.New(os.Stdout, "[negroni] ", 0), dateFormat: LoggerDefaultDateFormat}
	logger.SetFormat(LoggerDefaultFormat)
	return logger
}
625467
func NewLogger() *Logger {
	logger := &coreLogger{
		ErrorWriter: os.Stderr,
		BufferSize:  1024,
		MaxLevel:    LevelDebug,
		Targets:     make([]Target, 0),
	}
	return &Logger{logger, "app", DefaultFormatter}
}
22614
func NewLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
	return newLogger(stdoutThreshold, logThreshold, outHandle, logHandle, saveErrors)
}
210263
func NewFormatLogWriter(out io.Writer, format string) FormatLogWriter {
	records := make(FormatLogWriter, LogBufferLength)
	go records.run(out, format)
	return records
}
404522
func Logger(logger *log.Logger) ReporterOption {
	return func(c *kafkaReporter) {
		c.logger = logger
	}
}
1130379
func NewLogWatcher() *LogWatcher {
	return &LogWatcher{
		Msg:          make(chan *Message, logWatcherBufferSize),
		Err:          make(chan error, 1),
		producerGone: make(chan struct{}),
		consumerGone: make(chan struct{}),
	}
}