// NewSplunkLogger constructs a new Sender implementation that sends
// messages to a Splunk event collector using the credentials specified
// in the SplunkConnectionInfo struct.
546822
func NewSplunkLogger(name string, info SplunkConnectionInfo, l LevelInfo) (Sender, error) {
	s := &splunkLogger{
		info:   info,
		client: &splunkClientImpl{},
		Base:   NewBase(name),
	}

	hostname, err := os.Hostname()
	if err != nil {
		return nil, err
	}
	s.hostname = hostname

	if err := s.client.Create(info.ServerURL, info.Token, info.Channel); err != nil {
		return nil, err
	}

	if err := s.SetLevel(l); err != nil {
		return nil, err
	}

	return s, nil
}
1005184
func NewStdLogger(time, debug, trace, colors, pid bool) *Logger {
	flags := 0
	if time {
		flags = log.LstdFlags | log.Lmicroseconds
	}

	pre := ""
	if pid {
		pre = pidPrefix()
	}

	l := &Logger{
		logger: log.New(os.Stderr, pre, flags),
		debug:  debug,
		trace:  trace,
	}

	if colors {
		setColoredLabelFormats(l)
	} else {
		setPlainLabelFormats(l)
	}

	return l
}
1107667
func NewScheduler(name string, logger log.Logger, state State, planner Planner) (Scheduler, error) {
	// Lookup the factory function
	factory, ok := BuiltinSchedulers[name]
	if !ok {
		return nil, fmt.Errorf("unknown scheduler '%s'", name)
	}

	// Instantiate the scheduler
	sched := factory(logger, state, planner)
	return sched, nil
}
531625
func NewSlowLogParser(file *os.File, opt log.Options) *SlowLogParser {
	if opt.DefaultLocation == nil {
		// Old MySQL format assumes time is taken from SYSTEM.
		opt.DefaultLocation = time.Local
	}
	p := &SlowLogParser{
		file: file,
		opt:  opt,
		// --
		stopChan:    make(chan bool, 1),
		eventChan:   make(chan *log.Event),
		inHeader:    false,
		inQuery:     false,
		headerLines: 0,
		queryLines:  0,
		lineOffset:  0,
		bytesRead:   opt.StartOffset,
		event:       log.NewEvent(),
	}
	return p
}
643823
func NewStreamHandler(
	name string, level LogLevelType, stream Stream) *StreamHandler {

	object := &StreamHandler{
		BaseHandler: NewBaseHandler(name, level),
		stream:      stream,
	}
	Closer.AddHandler(object)
	return object
}
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
}
272945
func (e *Endpoint) Logger(subsystem string) *logrus.Entry {
	if e == nil {
		return log.WithField(logfields.LogSubsys, subsystem)
	}

	return e.getLogger().WithField(logfields.LogSubsys, subsystem)
}
197685
func NewSentryHook(DSN string, levels []logrus.Level) (*SentryHook, error) {
	client, err := raven.New(DSN)
	if err != nil {
		return nil, err
	}
	return NewWithClientSentryHook(client, levels)
}
1315042
func NewSubscriberWrapper() server.SubscriberWrapper {
	return func(next server.SubscriberFunc) server.SubscriberFunc {
		return func(ctx context.Context, msg server.Message) (err error) {
			t := newPublicationTracker(msg, ServerProfile)
			ctx = t.StartSpanFromContext(ctx)
			defer func() {
				t.finishWithError(err, noDebugStack)
			}()

			err = next(ctx, msg)
			return
		}
	}
}
1313329
func NewErrorLogger(name string, l LevelInfo) (Sender, error) {
	return setup(MakeErrorLogger(), name, l)
}
1085529
func newBlockProgressLogger(progressMessage string, logger btclog.Logger) *blockProgressLogger {
	return &blockProgressLogger{
		lastBlockLogTime: time.Now(),
		progressAction:   progressMessage,
		subsystemLogger:  logger,
	}
}
711096
func NewGithubIssuesLogger(name string, opts *GithubOptions) (Sender, error) {
	s := &githubLogger{
		Base: NewBase(name),
		opts: opts,
		gh:   &githubClientImpl{},
	}

	ctx := context.TODO()
	s.gh.Init(ctx, opts.Token)

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	if err := s.SetErrorHandler(ErrorHandlerFromLogger(fallback)); err != nil {
		return nil, err
	}

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

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

	return s, nil
}
711998
func NewNopLogger() Logger {
	return NewLoggerFromLogrus(&logrus.Logger{
		Out:       ioutil.Discard,
		Formatter: new(logrus.JSONFormatter),
		Level:     logrus.DebugLevel,
	})
}
192126
func (conn *ProtoConnection) NewSyncPublisher(topic string) (messaging.ProtoPublisher, error) {
	return &protoSyncPublisherKafka{conn, topic}, nil
}
14021
func NewServiceManager(
	isRunning func() bool,
	newService func(string, common.Conf) (Service, error),
) SystemdServiceManager {
	return &systemdServiceManager{
		isRunning:  isRunning,
		newService: newService,
	}
}
735828
func NewPlainFileLogger(name, file string, l LevelInfo) (Sender, error) {
	s, err := MakePlainFileLogger(file)
	if err != nil {
		return nil, err
	}

	return setup(s, name, l)
}
1260257
func NewSlackLogger(opts *SlackOptions, token string, l LevelInfo) (Sender, error) {
	if err := opts.Validate(); err != nil {
		return nil, err
	}

	s := &slackJournal{
		opts: opts,
		Base: NewBase(opts.Name),
	}

	s.opts.client.Create(token)

	if err := s.SetLevel(l); err != nil {
		return nil, err
	}

	if _, err := s.opts.client.AuthTest(); err != nil {
		return nil, fmt.Errorf("slack authentication error: %v", err)
	}

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	if err := s.SetErrorHandler(ErrorHandlerFromLogger(fallback)); err != nil {
		return nil, err
	}

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

	s.SetName(opts.Name)

	return s, nil
}