// setupLogging sets the logging verbosity level based on configuration
// and environment variables
191193
func setupLogging() {
	loglevel := config.LogLevel
	if loglevel == "" {
		loglevel = os.Getenv("TEXTSECURE_LOGLEVEL")
	}

	switch strings.ToUpper(loglevel) {
	case "DEBUG":
		log.SetLevel(log.DebugLevel)
	case "INFO":
		log.SetLevel(log.InfoLevel)
	case "WARN":
		log.SetLevel(log.WarnLevel)
	case "ERROR":
		log.SetLevel(log.ErrorLevel)
	default:
		log.SetLevel(log.ErrorLevel)
	}

	log.SetFormatter(&log.TextFormatter{
		FullTimestamp:   true,
		TimestampFormat: "2006/01/02 15:04:05",
	})
}
20243
func (m *MockImplementation) SetupConfig(registerer registerer.Registerer, cfg interface{}) error {
	ret := m.ctrl.Call(m, "SetupConfig", registerer, cfg)
	ret0, _ := ret[0].(error)
	return ret0
}
423179
func (l *LinuxMonitor) SetupConfig(registerer registerer.Registerer, cfg interface{}) error {

	if cfg == nil {
		cfg = DefaultConfig(false, false)
	}

	linuxConfig, ok := cfg.(*Config)
	if !ok {
		return fmt.Errorf("Invalid configuration specified")
	}

	if registerer != nil {
		if linuxConfig.SSH {
			if err := registerer.RegisterProcessor(common.SSHSessionPU, l.proc); err != nil {
				return err
			}
		} else {
			if err := registerer.RegisterProcessor(common.HostNetworkPU, l.proc); err != nil {
				return err
			}
			if err := registerer.RegisterProcessor(common.HostPU, l.proc); err != nil {
				return err
			}
			if err := registerer.RegisterProcessor(common.LinuxProcessPU, l.proc); err != nil {
				return err
			}
		}
	}

	// Setup defaults
	linuxConfig = SetupDefaultConfig(linuxConfig)

	// Setup config
	l.proc.host = linuxConfig.Host
	l.proc.ssh = linuxConfig.SSH
	l.proc.netcls = cgnetcls.NewCgroupNetController(common.TriremeCgroupPath, linuxConfig.ReleasePath)

	l.proc.regStart = regexp.MustCompile("^[a-zA-Z0-9_]{1,11}$")
	l.proc.regStop = regexp.MustCompile("^/trireme/[a-zA-Z0-9_]{1,11}$")

	l.proc.metadataExtractor = linuxConfig.EventMetadataExtractor
	if l.proc.metadataExtractor == nil {
		return fmt.Errorf("Unable to setup a metadata extractor")
	}

	return nil
}
1032440
func (m *fieldMessage) setup() {
	if _, ok := m.fields[FieldsMsgName]; !ok && m.message != "" {
		m.fields[FieldsMsgName] = m.message
	}

	if m.skipMetadata {
		return
	}

	_ = m.Collect()

	if b, ok := m.fields["metadata"]; !ok {
		m.fields["metadata"] = &m.Base
	} else if _, ok = b.(*Base); ok {
		m.fields["metadata"] = &m.Base
	}
}
594678
func (s *Service) setup() error {
	for _, m := range s.modules {
		n := getModuleName(m)
		c := s.configs[n]
		if c.Setup != nil {
			BootPrintln("[service] setup", n)
			err := c.Setup()
			if err != nil {
				return err
			}
		}

		if s.Env.IsTest() && c.SetupTest != nil {
			BootPrintln("[service] setup for test", n)
			c.SetupTest()
		}
	}
	return nil
}
477458
func (s *UpdateMaintenanceWindowTaskInput) SetLoggingInfo(v *LoggingInfo) *UpdateMaintenanceWindowTaskInput {
	s.LoggingInfo = v
	return s
}
294430
func (s *UpdateProjectInput) SetLogsConfig(v *LogsConfig) *UpdateProjectInput {
	s.LogsConfig = v
	return s
}
382039
func (s *AudioNormalizationSettings) SetLoudnessLogging(v string) *AudioNormalizationSettings {
	s.LoudnessLogging = &v
	return s
}
37103
func (agent *Agent) configureLogging(ctx context.Context) (context.Context, error) {
	log := fmt.Sprintf("agent.%s.log", strconv.FormatInt(time.Now().Unix(), 10))
	if err := os.MkdirAll(agent.logsDir, 0755); err != nil {
		return ctx, err
	}

	// TODO(smut): Capture logging emitted before configureLogging was called and
	// write it to the log file.
	out, err := os.OpenFile(filepath.Join(agent.logsDir, log), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
	if err != nil {
		return ctx, err
	}
	config := gologger.LoggerConfig{Out: out}
	return teelogger.Use(ctx, config.NewLogger), nil
}
399500
func (s *GetUploadOutput) SetUpload(v *Upload) *GetUploadOutput {
	s.Upload = v
	return s
}
457914
func SetupLoggingForLevels(token, env string, levels []logrus.Level) {
	setupLogging(token, env, levels)
}
928862
func (p *WindowsParser) Setup() error {
	t, err := tty.Open()
	if err != nil {
		return err
	}
	p.tty = t
	return nil
}
126760
func (m *Registry) Setup() {
	m.Lock()
	defer m.Unlock()

	// add some memory data
	m.Services = Data
}
181519
func setup(c *caddy.Controller) error {
	resource, err := expVarParse(c)
	if err != nil {
		return err
	}

	// publish any extra information/metrics we may want to capture
	publishExtraVars()

	ev := ExpVar{Resource: resource}

	httpserver.GetConfig(c).AddMiddleware(func(next httpserver.Handler) httpserver.Handler {
		ev.Next = next
		return ev
	})

	return nil
}
807540
func (p *Plugin) setLoggerLogLevel(name string, level string) error {
	p.Log.Debugf("SetLogLevel name %q, level %q", name, level)

	return p.LogRegistry.SetLevel(name, level)
}
867302
func (m *Command) setupLogger() error {
	if m.Config.LogPath == "" {
		m.logOutput = m.Stderr
	} else {
		f, err := os.OpenFile(m.Config.LogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600)
		if err != nil {
			return errors.Wrap(err, "opening file")
		}
		m.logOutput = f
		err = syscall.Dup2(int(f.Fd()), int(os.Stderr.Fd()))
		if err != nil {
			return errors.Wrap(err, "dup2ing stderr onto logfile")
		}
	}

	if m.Config.Verbose {
		m.logger = logger.NewVerboseLogger(m.logOutput)
	} else {
		m.logger = logger.NewStandardLogger(m.logOutput)
	}
	return nil
}
90368
func (s *Cluster) SetLogging(v *Logging) *Cluster {
	s.Logging = v
	return s
}