// MakeNative returns an unconfigured native standard-out logger. You
// *must* call SetName on this instance before using it. (Journaler's
// SetSender will typically do this.)
505249
func MakeNative() Sender {
	s := &nativeLogger{
		Base: NewBase(""),
	}

	_ = s.SetFormatter(MakeDefaultFormatter())

	s.level = LevelInfo{level.Trace, level.Trace}

	s.reset = func() {
		prefix := fmt.Sprintf("[%s] ", s.Name())
		s.logger = log.New(os.Stdout, prefix, log.LstdFlags)
		_ = s.SetErrorHandler(ErrorHandlerFromLogger(s.logger))
	}

	// we don't call reset here because name isn't set yet, and
	// SetName/SetSender will always call it. The potential for a nil
	// pointer is not 0

	return s
}
7928
func (me *Logger) SetPrefix(prefix string) {
	me.prefix = prefix
	me.logger.SetPrefix(prefix)
}
666033
func WindowsNativeANSI() bool {
	enabled, _ := windowsNativeANSI(true, false, nil)
	if enabled {
		return enabled
	}
	enabled, _ = windowsNativeANSI(false, false, nil)
	return enabled
}
1203676
func (l *intLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger {
	if opts == nil {
		opts = &StandardLoggerOptions{}
	}

	return log.New(l.StandardWriter(opts), "", 0)
}
998253
func NewSNativeContract(comment, name string,
	functions ...*SNativeFunctionDescription) *SNativeContractDescription {

	functionsByID := make(map[abi.FunctionID]*SNativeFunctionDescription, len(functions))
	for _, f := range functions {

		f.Abi = *abi.SpecFromStructReflect(f.Name, f.Arguments, f.Returns)
		fid := f.Abi.FunctionID
		otherF, ok := functionsByID[fid]
		if ok {
			panic(fmt.Errorf("function with ID %x already defined: %s", fid, otherF.Signature()))
		}
		functionsByID[fid] = f
	}
	return &SNativeContractDescription{
		Comment:       comment,
		Name:          name,
		functionsByID: functionsByID,
		functions:     functions,
	}
}
363627
func (vm *VM) NativeFunction(f *NativeFunction) {
	vm.nativeFuncs[f.Name] = f
}
37866
func SetOutput(domain string, level Level, w io.WriteCloser, commiter func(sl *Slog), formatter func(l *Slog) ([]byte, error), nl int) error {
	log = &Slog{
		Commit:    commiter,
		Formatter: formatter,
		Writter:   w,
		Level:     level,
	}
	err := log.Init(domain, nl)
	if err != nil {
		return e.Forward(err)
	}
	return nil
}
726995
func (n *Node) SetLogger(l log.Logger) {
	n.logger = l
	n.em.SetLogger(l)
}
257602
func MakeSysLogger(network, raddr string) Sender {
	s := &syslogger{Base: NewBase("")}

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	_ = s.SetErrorHandler(ErrorHandlerFromLogger(fallback))

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

		if s.logger != nil {
			if err := s.logger.Close(); err != nil {
				s.ErrorHandler(err, message.NewErrorWrapMessage(level.Error, err,
					"problem closing syslogger"))
			}
		}

		w, err := syslog.Dial(network, raddr, syslog.LOG_DEBUG, s.Name())
		if err != nil {
			s.ErrorHandler(err, message.NewErrorWrapMessage(level.Error, err,
				"error restarting syslog [%s] for logger: %s", err.Error(), s.Name()))
			return
		}

		s.closer = func() error {
			return w.Close()
		}

		s.logger = w
	}

	return s
}
1123427
func MakePlainFileLogger(filePath string) (Sender, error) {
	s := &nativeLogger{Base: NewBase("")}

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

	f, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		return nil, fmt.Errorf("error opening logging file, %s", err.Error())
	}

	s.level = LevelInfo{level.Trace, level.Trace}

	fallback := log.New(os.Stderr, "", log.LstdFlags)
	_ = s.SetErrorHandler(ErrorHandlerFromLogger(fallback))

	s.reset = func() {
		s.logger = log.New(f, "", 0)
	}

	s.closer = func() error {
		return f.Close()
	}

	return s, nil
}
823510
func (l *Logger) makeLog(msg interface{}, lvl Level, data []interface{}) {
	log := Log{
		Time:    time.Now().UTC(),
		Message: l.toString(msg),
		Level:   lvl,
		Data:    data,
		Logger:  l,
		Pid:     os.Getpid(),
		Ctx:     l.ctx,
	}

	for _, appender := range l.appenders {
		appender.Append(log)
	}
}
384663
func FuncFromNative(fn func(*Thread, []Value, []Value), t *FuncType) FuncValue {
	return &funcV{&nativeFunc{fn, len(t.In), len(t.Out)}}
}
784766
func LangNativeName(s string) (string, error) {
	_, nat, err := LangCodeInfo(s)
	return nat, err
}
375765
func Init(homeDir, mobileSharedHome, logFile, runModeStr string,
	accessGroupOverride bool, externalDNSNSFetcher ExternalDNSNSFetcher, nvh NativeVideoHelper) (err error) {
	defer func() {
		err = flattenError(err)
		if err == nil {
			setInited()
		}
	}()

	fmt.Printf("Go: Initializing: home: %s mobileSharedHome: %s\n", homeDir, mobileSharedHome)
	var ekLogFile string
	if logFile != "" {
		fmt.Printf("Go: Using log: %s\n", logFile)
		ekLogFile = logFile + ".ek"
		fmt.Printf("Go: Using eklog: %s\n", ekLogFile)
	}

	// Reduce OS threads on mobile so we don't have too much contention with JS thread
	oldProcs := runtime.GOMAXPROCS(0)
	newProcs := oldProcs / 2
	runtime.GOMAXPROCS(newProcs)
	fmt.Printf("Go: setting GOMAXPROCS to: %d previous: %d\n", newProcs, oldProcs)

	startTrace(logFile)

	dnsNSFetcher := newDNSNSFetcher(externalDNSNSFetcher)
	dnsServers := dnsNSFetcher.GetServers()
	for _, srv := range dnsServers {
		fmt.Printf("Go: DNS Server: %s\n", srv)
	}

	kbCtx = libkb.NewGlobalContext()
	kbCtx.Init()
	kbCtx.SetProofServices(externals.NewProofServices(kbCtx))

	// 10k uid -> FullName cache entries allowed
	kbCtx.SetUIDMapper(uidmap.NewUIDMap(10000))
	usage := libkb.Usage{
		Config:    true,
		API:       true,
		KbKeyring: true,
	}
	runMode, err := libkb.StringToRunMode(runModeStr)
	if err != nil {
		return err
	}
	config := libkb.AppConfig{
		HomeDir:                        homeDir,
		MobileSharedHomeDir:            mobileSharedHome,
		LogFile:                        logFile,
		EKLogFile:                      ekLogFile,
		RunMode:                        runMode,
		Debug:                          true,
		LocalRPCDebug:                  "",
		VDebugSetting:                  "mobile", // use empty string for same logging as desktop default
		SecurityAccessGroupOverride:    accessGroupOverride,
		ChatInboxSourceLocalizeThreads: 5,
		LinkCacheSize:                  1000,
	}
	err = kbCtx.Configure(config, usage)
	if err != nil {
		return err
	}

	svc := service.NewService(kbCtx, false)
	err = svc.StartLoopbackServer()
	if err != nil {
		return err
	}
	kbCtx.SetService()
	uir := service.NewUIRouter(kbCtx)
	kbCtx.SetUIRouter(uir)
	kbCtx.SetDNSNameServerFetcher(dnsNSFetcher)
	svc.SetupCriticalSubServices()
	svc.SetupChatModules(nil)
	svc.RunBackgroundOperations(uir)
	kbChatCtx = svc.ChatContextified.ChatG()
	kbChatCtx.NativeVideoHelper = newVideoHelper(nvh)

	logs := libkb.Logs{
		Service: config.GetLogFile(),
		EK:      config.GetEKLogFile(),
	}

	fmt.Printf("Go: Using config: %+v\n", kbCtx.Env.GetLogFileConfig(config.GetLogFile()))

	logSendContext = libkb.LogSendContext{
		Contextified: libkb.NewContextified(kbCtx),
		Logs:         logs,
	}

	// open the connection
	if err = Reset(); err != nil {
		return err
	}

	go func() {
		kbfsCtx := env.NewContextFromGlobalContext(kbCtx)
		kbfsParams := libkbfs.DefaultInitParams(kbfsCtx)
		// Setting this flag will enable KBFS debug logging to always
		// be true in a mobile setting. Change these back to the
		// commented-out values if we need to make a mobile release
		// before KBFS-on-mobile is ready.
		kbfsParams.Debug = true                         // false
		kbfsParams.Mode = libkbfs.InitConstrainedString // libkbfs.InitMinimalString
		kbfsConfig, _ = libkbfs.Init(
			context.Background(), kbfsCtx, kbfsParams, serviceCn{}, func() error { return nil },
			kbCtx.Log)
	}()

	return nil
}
339539
func SetLogger(l *log.Logger, logLevel string) {
	logger = l
	LogLevelSet(logLevel)
}
728211
func (lgr *logger) SetLogger(l genericLogger) {
	lgr.mutex.Lock()
	defer lgr.mutex.Unlock()

	lgr.Logger = l
}
414004
func (se *Engine) MakeNonMaster() {
	// This function is tested through endtoend test.
	se.mu.Lock()
	defer se.mu.Unlock()
	for _, t := range se.tables {
		if t.SequenceInfo != nil {
			t.SequenceInfo.Lock()
			t.SequenceInfo.NextVal = 0
			t.SequenceInfo.LastVal = 0
			t.SequenceInfo.Unlock()
		}
	}
}