// Initialize the root logger with the name "root".
965148
func NewRootLogger(level LogLevelType) *RootLogger {
	logger := NewStandardLogger("root", level)
	logger.SetPropagate(false)
	return &RootLogger{
		StandardLogger: logger,
	}
}
1211457
func InitLog(params InitParams, ctx Context) (logger.Logger, error) {
	return InitLogWithPrefix(params, ctx, "kbfs", defaultLogPath(ctx))
}
95546
func Init() {
	// Root path is automatically determined from the calling function's source file location.
	// Catch the calling function's source file path.
	_, file, _, _ := runtime.Caller(1)
	// Save the directory alone.
	rootPath = filepath.Dir(file)

	appInfo = make(map[string]string)
}
796771
func InitLogger(logLevel int) {
	SetLogLevel(logLevel)
	if logLevel <= LDebug {
		log.SetFlags(log.LstdFlags | log.Lshortfile)
	}
}
516388
func init() {
	log = logger.New()
	log.Out = os.Stdout
	log.Level = logger.DebugLevel
}
677326
func Init(root string, _ []string) (volume.Driver, error) {
	driver := &RsyncDriver{
		root: root,
	}
	if err := os.MkdirAll(driver.MetadataDir(), 0755); err != nil && !os.IsExist(err) {
		return nil, err
	}
	if err := volume.TouchFlagFile(driver.poolDir()); err != nil {
		return nil, err
	}
	return driver, nil
}
804651
func (s *Application) RootDir() string {
	if len(s.rootDir) == 0 {
		ppath := os.Getenv(strings.ToUpper(s.Name) + `PATH`)
		if len(ppath) == 0 {
			ppath, _ = filepath.Abs(os.Args[0])
			ppath = filepath.Dir(ppath)
		}
		s.rootDir = ppath
	}
	return s.rootDir
}
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()
	}
}
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)
}
1020150
func initFileLog(cfg *zaplog.FileLogConfig, logger *log.Logger) error {
	if st, err := os.Stat(cfg.Filename); err == nil {
		if st.IsDir() {
			return errors.New("can't use directory as log file name")
		}
	}
	if cfg.MaxSize == 0 {
		cfg.MaxSize = DefaultLogMaxSize
	}

	// use lumberjack to logrotate
	output := &lumberjack.Logger{
		Filename:   cfg.Filename,
		MaxSize:    int(cfg.MaxSize),
		MaxBackups: int(cfg.MaxBackups),
		MaxAge:     int(cfg.MaxDays),
		LocalTime:  true,
	}

	if logger == nil {
		log.SetOutput(output)
	} else {
		logger.Out = output
	}
	return nil
}
1295911
func Init() {
	mu.Lock()
	defer mu.Unlock()
	if inited {
		log.Fatal("servenv.Init called second time")
	}
	inited = true

	// Once you run as root, you pretty much destroy the chances of a
	// non-privileged user starting the program correctly.
	if uid := os.Getuid(); uid == 0 {
		log.Exitf("servenv.Init: running this as root makes no sense")
	}

	runtime.MemProfileRate = *memProfileRate

	if *mutexProfileFraction != 0 {
		log.Infof("setting mutex profile fraction to %v", *mutexProfileFraction)
		runtime.SetMutexProfileFraction(*mutexProfileFraction)
	}

	// We used to set this limit directly, but you pretty much have to
	// use a root account to allow increasing a limit reliably. Dropping
	// privileges is also tricky. The best strategy is to make a shell
	// script set up the limits as root and switch users before starting
	// the server.
	fdLimit := &syscall.Rlimit{}
	if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, fdLimit); err != nil {
		log.Errorf("max-open-fds failed: %v", err)
	}
	fdl := stats.NewGauge("MaxFds", "File descriptor limit")
	fdl.Set(int64(fdLimit.Cur))

	onInitHooks.Fire()
}
544097
func (l *JSONLogger) InitLogger() error {
	if len(l.config.HostURI) == 0 {
		return fmt.Errorf("A HostURI must be set")
	}
	hostURL, err := url.Parse(l.config.HostURI)
	if err != nil {
		return fmt.Errorf("Invalid HostURI: %v", err)
	}
	if !strings.Contains(hostURL.Host, ":") {
		return fmt.Errorf("A port must be provided")
	}
	l.hostURL = hostURL

	l.unprefixedMap = make(map[string]bool)
	for _, fieldName := range l.config.UnprefixedFields {
		l.unprefixedMap[fieldName] = true
	}

	if err := l.connect(); err != nil {
		if !l.config.AllowDisconnectedInit {
			return err
		}

		// Reconnect in background
		l.performReconnect()
	}

	l.isInitialized = true
	return nil
}
400532
func (i *IDMappings) RootPair() IDPair {
	uid, gid, _ := GetRootUIDGID(i.uids, i.gids)
	return IDPair{UID: uid, GID: gid}
}
388866
func (a *AddDeps) Root(c context.Context) *ds.Key {
	return model.AttemptKeyFromID(c, a.Auth.Id.AttemptID())
}
1236027
func (app *App) Initialize() {
	log.Println("App Initialize")

	app.AddForm("login", forms.FormLogin{})
	app.AddForm("home", forms.FormHome{})

	app.GoTo("login", nil)
}
1100059
func init() {
	dcrsqlite.UseLogger(sqliteLog)
	dcrpg.UseLogger(postgresqlLog)
	stakedb.UseLogger(stakedbLog)
	blockdata.UseLogger(BlockdataLog)
	rpcclient.UseLogger(clientLog)
	rpcutils.UseLogger(clientLog)
	mempool.UseLogger(mempoolLog)
	explorer.UseLogger(expLog)
	api.UseLogger(apiLog)
	insight.UseLogger(iapiLog)
	middleware.UseLogger(apiLog)
	notify.UseLogger(notifyLog)
	pubsub.UseLogger(pubsubLog)
	exchanges.UseLogger(xcBotLog)
	agendas.UseLogger(agendasLog)
	politeia.UseLogger(proposalsLog)
}
840420
func InitLogging(binary string, ctx *cli.Context) error {
	logLevel, err := logrus.ParseLevel(ctx.String("log-level"))
	if err != nil {
		return err
	}
	logrus.SetLevel(logLevel)
	logrus.Infof("Using %v log level: %v", binary, logLevel)

	if ctx.Bool("use-syslog") {
		syslogURL := ctx.String("syslog-url")
		if err := configureSyslog(binary, logLevel, syslogURL); err != nil {
			return err
		}
		logrus.Infof("Using %v syslog config: %v", binary, syslogURL)
	} else {
		logrus.Infof("Using %v syslog config: nil", binary)
	}

	if ctx.Bool("use-json-log") {
		logrus.SetFormatter(&logrus.JSONFormatter{})
		logrus.Infof("Using %v log format: json", binary)
	} else {
		logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true, TimestampFormat: time.StampNano})
		logrus.Infof("Using %v log format: text", binary)
	}
	return nil
}