// InitLog use for initial log module
556702
func InitLog() error {

	var err error

	// init logger
	LogAccess = logrus.New()
	LogError = logrus.New()

	LogAccess.Formatter = &logrus.TextFormatter{
		TimestampFormat: "2006/01/02 - 15:04:05",
		FullTimestamp:   true,
	}

	LogError.Formatter = &logrus.TextFormatter{
		TimestampFormat: "2006/01/02 - 15:04:05",
		FullTimestamp:   true,
	}

	// set logger
	if err = SetLogLevel(LogAccess, PushConf.Log.AccessLevel); err != nil {
		return errors.New("Set access log level error: " + err.Error())
	}

	if err = SetLogLevel(LogError, PushConf.Log.ErrorLevel); err != nil {
		return errors.New("Set error log level error: " + err.Error())
	}

	if err = SetLogOut(LogAccess, PushConf.Log.AccessLog); err != nil {
		return errors.New("Set access log path error: " + err.Error())
	}

	if err = SetLogOut(LogError, PushConf.Log.ErrorLog); err != nil {
		return errors.New("Set error log path error: " + err.Error())
	}

	return nil
}
1364081
func initialize() {
	defaultLogger = &Logger{
		infoLog:    log.New(os.Stderr, initText+tagInfo, flags),
		warningLog: log.New(os.Stderr, initText+tagWarning, flags),
		errorLog:   log.New(os.Stderr, initText+tagError, flags),
		fatalLog:   log.New(os.Stderr, initText+tagFatal, flags),
	}
}
24528
func InitLogger() {
	if !flag.Parsed() {
		flag.Parse()
	}
	if env_level,ok := os.LookupEnv("LOGGER_LEVEL");ok{
		*flagLoggerLevel = env_level
	}
	SetDefaultLevel("/", getLevel(*flagLoggerLevel))
	Info("设置默认日志级别为:%s", *flagLoggerLevel)
}
1118550
func initConfig() {
	if viper.GetBool("debug") {
		log.Level = logrus.DebugLevel
	} else {
		log.Level = logrus.InfoLevel
	}
}
1315531
func initRequestLog(c *CompositeMultiHandler, basePath string, config *config.Context) {
	// Request logging to a separate output handler
	// This takes the InfoHandlers and adds a MatchAbHandler handler to it to direct
	// context with the word "section=requestlog" to that handler.
	// Note if request logging is not enabled the MatchAbHandler will not be added and the
	// request log messages will be sent out the INFO handler
	outputRequest := "stdout"
	if config != nil {
		outputRequest = config.StringDefault("log.request.output", "")
	}
	oldInfo := c.InfoHandler
	c.InfoHandler = nil
	if outputRequest != "" {
		initHandlerFor(c, outputRequest, basePath, NewLogOptions(config, false, nil, LvlInfo))
	}
	if c.InfoHandler != nil || oldInfo != nil {
		if c.InfoHandler == nil {
			c.InfoHandler = oldInfo
		} else {
			c.InfoHandler = MatchAbHandler("section", "requestlog", c.InfoHandler, oldInfo)
		}
	}
}
541915
func InitLogs() {
	log.SetOutput(GlogWriter{})
	log.SetFlags(0)
	// The default glog flush interval is 30 seconds, which is frighteningly long.
	go Until(glog.Flush, *logFlushFreq, NeverStop)
}
440125
func (l *Logger) SetLogInit(fn func(Log, *gear.Context)) *Logger {
	l.mu.Lock()
	defer l.mu.Unlock()
	l.init = fn
	return l
}
1160928
func initLogrus() func() {
	// Initialize logger.LogrusHookBuffer
	logrusHookBuffer = logger.NewLogrusHookBuffer()

	// Initialize logging. All logging is done via logrusHookBuffer;
	// logrus's output writer is always set to ioutil.Discard.
	logrus.AddHook(&logrusHookBuffer)
	logrus.SetOutput(ioutil.Discard)
	logrus.SetLevel(getLogrusLevel(*flagLoglevel))

	switch *flagLogColors {
	case "never", "auto", "always":
	default:
		fmt.Printf("Invalid parameter for -log-colors: '%s'\n", *flagLogColors)
		*flagLogColors = "auto"
	}

	if *flagLogColors == "always" ||
		(*flagLogColors == "auto" && terminal.IsTerminal(int(logger.FallbackLogDevice.Fd()))) {
		// Logrus doesn't know the final log device, so we hint the color option here
		logrus.SetFormatter(logger.NewConsoleFormatter())
	}

	// make sure logs are purged at exit
	return func() {
		logrusHookBuffer.SetTargetWriter(logger.FallbackLogDevice)
		logrusHookBuffer.Purge()
	}
}
630244
func init() {
	lnwallet.UseLogger(lnwlLog)
	discovery.UseLogger(discLog)
	chainntnfs.UseLogger(ntfnLog)
	channeldb.UseLogger(chdbLog)
	htlcswitch.UseLogger(hswcLog)
	connmgr.UseLogger(cmgrLog)
	routing.UseLogger(crtrLog)
	neutrino.UseLogger(btcnLog)
	autopilot.UseLogger(atplLog)
	contractcourt.UseLogger(cnctLog)
	sphinx.UseLogger(sphxLog)
	signal.UseLogger(ltndLog)
	sweep.UseLogger(swprLog)
	signrpc.UseLogger(sgnrLog)
	walletrpc.UseLogger(wlktLog)
	autopilotrpc.UseLogger(arpcLog)
	invoices.UseLogger(invcLog)
	netann.UseLogger(nannLog)
	watchtower.UseLogger(wtwrLog)
	chainrpc.UseLogger(ntfrLog)
	invoicesrpc.UseLogger(irpcLog)
	channelnotifier.UseLogger(chnfLog)
	chanbackup.UseLogger(chbuLog)

	addSubLogger(routerrpc.Subsystem, routerrpc.UseLogger)
}
189163
func (m *Module) Init(c *service.Config) {
	c.Start = func() {
		for _, p := range m.oauthConfigs {
			m.register(p)
		}
	}
}
1038771
func initializeLogging(logFile, logLevel string) {
	log = backendLog.Logger("SRVR")
	exchanges.UseLogger(xcLogger)
	logDir, _ := filepath.Split(logFile)
	err := os.MkdirAll(logDir, 0700)
	if err != nil {
		log.Errorf("failed to create log directory: %v", err)
		os.Exit(1)
	}
	r, err := rotator.New(logFile, 10*1024, false, 3)
	if err != nil {
		log.Errorf("failed to create file rotator: %v\n", err)
		os.Exit(1)
	}
	logRotator = r
	if logLevel != "" {
		level, ok := slog.LevelFromString(logLevel)
		if ok {
			log.SetLevel(level)
			xcLogger.SetLevel(level)
		} else {
			log.Infof("Unable to assign logging level=%s. Falling back to level=info", logLevel)
		}
	}
}
1095944
func (lc *logConfig) initIfNeeded() {
	if getLogLevelContext(rootLoggerName, lc.logContexts) != nil {
		return
	}
	lc.setConfigParams(defaultConfigParams)
}
706820
func (p *Parser) Init(options interface{}) error {
	p.conf = *options.(*Options)
	lineParser, err := NewSyslogLineParser(p.conf.Mode, p.conf.ProcessList)
	if err != nil {
		return err
	}
	p.lineParser = lineParser
	return nil
}
351549
func Init() {
	switch *streamlog.QueryLogFormat {
	case streamlog.QueryLogFormatText:
	case streamlog.QueryLogFormatJSON:
	default:
		log.Exitf("Invalid querylog-format value %v: must be either text or json", *streamlog.QueryLogFormat)
	}

	if *queryLogHandler != "" {
		StatsLogger.ServeLogs(*queryLogHandler, streamlog.GetFormatter(StatsLogger))
	}

	if *txLogHandler != "" {
		TxLogger.ServeLogs(*txLogHandler, streamlog.GetFormatter(TxLogger))
	}
}
1169
func Initialize(l api.LoggerProvider) {
	loggerProviderOnce.Do(func() {
		loggerProviderInstance = l
		logger := loggerProviderInstance.GetLogger(loggerModule)
		logger.Debug("Logger provider initialized")

		// TODO
		// use custom leveler implementation (otherwise fallback to default)
		//		levelerProvider, ok := loggingProvider.(apilogging.Leveler)
		//		if !ok {
		//		}
	})
}
265007
func InitializeLogger(logJSON bool, lvl string) {
	logger = logrus.New()

	logLevel, err := logrus.ParseLevel(lvl)
	if err != nil {
		logrus.Warnf("unable to parse log level configuration error: %q", err)
		logLevel = logrus.ErrorLevel // reset to ERROR
	}
	logrus.SetLevel(logLevel)
	logger.Level = logLevel

	if logJSON {
		customFormatter := new(logrus.JSONFormatter)
		customFormatter.TimestampFormat = "2006-01-02 15:04:05"

		logrus.SetFormatter(customFormatter)
		customFormatter.DisableTimestamp = false
		logger.Formatter = customFormatter
	} else {
		customFormatter := new(logrus.TextFormatter)
		customFormatter.FullTimestamp = true
		customFormatter.TimestampFormat = "2006-01-02 15:04:05"
		logrus.SetFormatter(customFormatter)
		logger.Formatter = customFormatter
	}

	logger.Out = os.Stdout
}
563728
func initLogLevels(c *CompositeMultiHandler, basePath string, config *config.Context) {
	for _, name := range []string{"debug", "info", "warn", "error", "crit",
		"trace", // TODO trace is deprecated
	} {
		if config != nil {
			extraLogFlag := config.BoolDefault(SPECIAL_USE_FLAG, false)
			output, found := config.String("log." + name + ".output")
			if found {
				if extraLogFlag {
					log.Printf("Adding standard handler %s output %s", name, output)
				}
				initHandlerFor(c, output, basePath, NewLogOptions(config, true, nil, toLevel[name]))
			}
			// Gets the list of options with said prefix
		} else {
			initHandlerFor(c, "stderr", basePath, NewLogOptions(config, true, nil, toLevel[name]))
		}
	}
}