// New returns a worker that will keep an up-to-date audit log config.
8945
func New(source ConfigSource, initial auditlog.Config, logFactory AuditLogFactory) (worker.Worker, error) {
	u := &updater{
		source:     source,
		current:    initial,
		logFactory: logFactory,
	}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &u.catacomb,
		Work: u.loop,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return u, 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
}
308304
func New(pool *redis.Pool, src, id string) *DefaultWorker {
	heartbeater := heartbeat.New(
		id,
		fmt.Sprintf("%s:%s", src, "ticks"),
		defaultHeartInterval, pool)

	return &DefaultWorker{
		pool:           pool,
		availableTasks: queue.NewByteQueue(pool, src),
		workingTasks:   queue.NewDurableQueue(pool, src, getWorkingQueueName(src, id)),

		lifecycle: NewLifecycle(pool),
		detector:  heartbeater.Detector(),
		heart:     heartbeater.Heart(),
		janitor:   nilJanitor{},

		state: closed,
	}
}
91519
func New(config ...*Config) *Worker {
	var cfg = &Config{}
	if len(config) > 0 {
		cfg = config[0]
	}

	if cfg.Job == nil {
		cfg.Job = &QorJob{}
	}

	if cfg.Queue == nil {
		cfg.Queue = NewCronQueue()
	}

	return &Worker{Config: cfg}
}
1007
func New() *Config {
	config := Config{}
	config.LogConfig.Config = make(map[string]string)
	config.ClusterOpts = make(map[string]string)

	return &config
}
1175107
func (l *Logger) New(ctx *gear.Context) (interface{}, error) {
	log := Log{}
	l.init(log, ctx)
	return log, nil
}
1213220
func New(indexPrefix, typeName, JobType, WorkerName string, Code, ElapsedTime int, success ...bool) *LogEntry {
	now := time.Now()
	index := fmt.Sprintf("%v-%04d-%02d-%02d", indexPrefix, now.Year(), now.Month(), now.Day())

	requestMetadata := RequestMetadata{JobType, WorkerName}
	request := Request{Metadata: requestMetadata}

	Success := (Code < 500)
	if len(success) > 0 {
		Success = success[0]
	}

	responseMetadata := ResponseMetadata{Code: Code, Success: Success}
	response := Response{Metadata: responseMetadata}

	Date := int((now.UnixNano() / 1000000)) - ElapsedTime
	body := Body{Request: request, Response: response, ElapsedTime: ElapsedTime, Date: Date, Index: index, Type: typeName}
	return &LogEntry{Index: index, Type: typeName, Body: body}
}
290579
func New(config Config) (*Worker, error) {
	if err := config.Validate(); err != nil {
		return nil, errors.Trace(err)
	}

	w := &Worker{
		config: config,
		logger: logger,
		runner: worker.NewRunner(worker.RunnerParams{
			Clock: config.Clock,

			// One of the remote application workers failing should not
			// prevent the others from running.
			IsFatal: func(error) bool { return false },

			// For any failures, try again in 1 minute.
			RestartDelay: time.Minute,
		}),
	}
	err := catacomb.Invoke(catacomb.Plan{
		Site: &w.catacomb,
		Work: w.loop,
		Init: []worker.Worker{w.runner},
	})
	return w, errors.Trace(err)
}
361459
func New(ctx ...interface{}) MultiLogger {
	r := &RevelLogger{Logger: log15.New(ctx...)}
	r.SetStackDepth(1)
	return r
}
75571
func New(name string) (*Config, error) {
	configsGuard.Lock()
	defer configsGuard.Unlock()
	if _, found := configs[name]; found {
		return nil, fmt.Errorf("register config %q twice", name)
	}
	newConfig := Config{}
	configs[name] = &newConfig
	return &newConfig, nil
}
294907
func New(config Config) (*Cache, error) {
	if err := config.CheckAndSetDefaults(); err != nil {
		return nil, trace.Wrap(err)
	}
	wrapper := backend.NewWrapper(config.Backend)
	ctx, cancel := context.WithCancel(config.Context)
	cs := &Cache{
		wrapper:            wrapper,
		ctx:                ctx,
		cancel:             cancel,
		Config:             config,
		trustCache:         local.NewCAService(wrapper),
		clusterConfigCache: local.NewClusterConfigurationService(wrapper),
		provisionerCache:   local.NewProvisioningService(wrapper),
		usersCache:         local.NewIdentityService(wrapper),
		accessCache:        local.NewAccessService(wrapper),
		presenceCache:      local.NewPresenceService(wrapper),
		eventsCache:        local.NewEventsService(config.Backend),
		Entry: log.WithFields(log.Fields{
			trace.Component: config.Component,
		}),
	}
	collections, err := setupCollections(cs, config.Watches)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	cs.collections = collections

	err = cs.fetch()
	if err != nil {
		// "only recent" behavior does not tolerate
		// stale data, so it has to initialize itself
		// with recent data on startup or fail
		if cs.OnlyRecent.Enabled {
			return nil, trace.Wrap(err)
		}
	}
	go cs.update()
	return cs, nil
}
550812
func (api *SimpleMonitorAPI) New(target string) *sacloud.SimpleMonitor {
	return sacloud.CreateNewSimpleMonitor(target)
}
565196
func New(projectID int64, projectKey string) *Handler {
	return NewFromNotifier(gobrake.NewNotifier(projectID, projectKey))
}
1204331
func New(logger hclog.Logger, shutdownCh chan struct{}, connPoolPinger Pinger) (m *Manager) {
	logger = logger.Named("server_mgr")
	return &Manager{
		logger:         logger,
		connPoolPinger: connPoolPinger,
		rebalanceTimer: time.NewTimer(clientRPCMinReuseDuration),
		shutdownCh:     shutdownCh,
	}
}
212179
func New(key string, flow FlowType, message string) *PersistentLog {
	return &PersistentLog{
		Timestamp: time.Now(),
		Flow:      flow,
		Key:       key,
		Message:   message,
	}
}
674681
func New(w io.Writer) *Logger {
	logger := &Logger{Out: w}
	logger.SetLevel(DebugLevel)
	logger.SetTimeFormat("2006-01-02T15:04:05.000Z")
	logger.SetLogFormat("[%s] %s %s")

	logger.init = func(log Log, ctx *gear.Context) {
		log["Start"] = time.Now()
		log["IP"] = ctx.IP().String()
		log["Proto"] = ctx.Req.Proto
		log["Method"] = ctx.Method
		log["URI"] = ctx.Req.RequestURI
		if s := ctx.GetHeader(gear.HeaderOrigin); s != "" {
			log["Origin"] = s
		}
		if s := ctx.GetHeader(gear.HeaderReferer); s != "" {
			log["Referer"] = s
		}
		log["UserAgent"] = ctx.GetHeader(gear.HeaderUserAgent)
	}

	logger.consume = func(log Log, ctx *gear.Context) {
		end := time.Now()
		if t, ok := log["Start"].(time.Time); ok {
			log["Start"] = t.UTC().Format(logger.tf)
			log["Time"] = end.Sub(t) / 1e6 // ms
		}

		if s := ctx.GetHeader(gear.HeaderXRequestID); s != "" {
			log["XRequestID"] = s
		} else if s := ctx.Res.Get(gear.HeaderXRequestID); s != "" {
			log["XRequestID"] = s
		}

		if router := gear.GetRouterPatternFromCtx(ctx); router != "" {
			log["Router"] = fmt.Sprintf("%s %s", ctx.Method, router)
		}

		if str, err := log.Format(); err == nil {
			logger.Output(end, InfoLevel, str)
		} else {
			logger.Output(end, WarningLevel, log.String())
		}
	}
	return logger
}
588160
func New(out io.Writer, flags FlagSet) *Logger {
	return NewFormatLogger(out, flags, &FormatWriterStructured{})
}