// start file logger. create log file and set to locker-inside file writer.
340249
func (w *FileLogWriter) startLogger() error {
	fd, err := w.createLogFile()
	if err != nil {
		return err
	}
	w.mw.SetFd(fd)
	return w.initFd()
}
829135
func (m *managerImpl) Start(diskInfoProvider DiskInfoProvider, podFunc ActivePodsFunc, podCleanedUpFunc PodCleanedUpFunc, monitoringInterval time.Duration) {
	thresholdHandler := func(message string) {
		klog.Infof(message)
		m.synchronize(diskInfoProvider, podFunc)
	}
	if m.config.KernelMemcgNotification {
		for _, threshold := range m.config.Thresholds {
			if threshold.Signal == evictionapi.SignalMemoryAvailable || threshold.Signal == evictionapi.SignalAllocatableMemoryAvailable {
				notifier, err := NewMemoryThresholdNotifier(threshold, m.config.PodCgroupRoot, &CgroupNotifierFactory{}, thresholdHandler)
				if err != nil {
					klog.Warningf("eviction manager: failed to create memory threshold notifier: %v", err)
				} else {
					go notifier.Start()
					m.thresholdNotifiers = append(m.thresholdNotifiers, notifier)
				}
			}
		}
	}
	// start the eviction manager monitoring
	go func() {
		for {
			if evictedPods := m.synchronize(diskInfoProvider, podFunc); evictedPods != nil {
				klog.Infof("eviction manager: pods %s evicted, waiting for pod to be cleaned up", format.Pods(evictedPods))
				m.waitForPodsCleanup(podCleanedUpFunc, evictedPods)
			} else {
				time.Sleep(monitoringInterval)
			}
		}
	}()
}
355091
func InitLogger(cfg *LogConfig) error {
	log.SetLevel(stringToLogLevel(cfg.Level))
	log.AddHook(&contextHook{})

	if cfg.Format == "" {
		cfg.Format = DefaultLogFormat
	}
	formatter := stringToLogFormatter(cfg.Format, cfg.DisableTimestamp)
	log.SetFormatter(formatter)

	if len(cfg.File.Filename) != 0 {
		if err := initFileLog(&cfg.File, nil); err != nil {
			return errors.Trace(err)
		}
	}

	if len(cfg.SlowQueryFile) != 0 {
		SlowQueryLogger = log.New()
		tmp := cfg.File
		tmp.Filename = cfg.SlowQueryFile
		if err := initFileLog(&tmp, SlowQueryLogger); err != nil {
			return errors.Trace(err)
		}
		SlowQueryLogger.Formatter = &slowLogFormatter{}
	}

	return nil
}
481546
func (p *Plugin) Start(ctx context.Context) error {
	p.logInfo("Starting decision log uploader.")
	go p.loop()
	return nil
}
305690
func NewFileLogger(f string, o, mode, maxLines, maxRotate, bufsize int) (*FileLogger, error) {
	var file *os.File
	var err error

	switch mode {
	case APPEND:
		// open log file, append if it already exists
		file, err = os.OpenFile(f, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
	case TRUNC:
		// just truncate file and start logging
		file, err = os.OpenFile(f, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
	case BACKUP:
		// rotate every time a new logger is created
		file, err = openBackup(f, 0, maxRotate)
	case ROTATE:
		// "normal" rotation, when file reaches line limit
		file, err = openBackup(f, maxLines, maxRotate)
	default:
		return nil, fmt.Errorf("Invalid mode parameter: %d", mode)
	}
	if err != nil {
		return nil, fmt.Errorf("Error creating logger: %s", err)
	}

	return newFileLogger(file, o, mode, maxLines, maxRotate, bufsize), nil
}
340142
func (c *Discovery) Start(ctx context.Context) error {
	if c.downloader != nil {
		c.downloader.Start(ctx)
	}
	return nil
}
587362
func init() {
	SetPrinter(printer.LogPrinter{})
	_, mainPath, _, _ = runtime.Caller(1)
	mainPath = filepath.Dir(mainPath)
}
621521
func (w *FileLogWriter) Init(config map[string]interface{}) error {
	if config == nil {
		return errors.New("config can not be empty")
	}
	if filename, ok := config["filename"]; !ok || len(filename.(string)) == 0 {
		return errors.New("config must have filename")
	}
	conf, err := json.Marshal(config)
	if err != nil {
		return err
	}
	err = json.Unmarshal(conf, w)
	if err != nil {
		return err
	}
	return w.startLogger()
}
221537
func (p *Process) Start() error {

	rand.Seed(time.Now().Unix())

	for i := 0; i < len(modules); i++ {
		glog.V(4).Infof("readconfig: %s\n", GetName(modules[i]))
		err := modules[i].ReadConfig(p.Configer)
		if err != nil {
			return err
		}
	}

	for i := 0; i < len(modules); i++ {
		glog.V(4).Infof("prestart: %s\n", GetName(modules[i]))
		if err := modules[i].Prestart(); err != nil {
			return err
		}
	}

	for i := 0; i < len(modules); i++ {
		glog.V(4).Infof("start: %s\n", GetName(modules[i]))
		if err := modules[i].Start(); err != nil {
			return err
		}
	}

	return nil
}
553178
func Start(c *exec.Cmd) (pty *os.File, err error) {
	return StartWithSize(c, nil)
}
113807
func (s *Syslog) Start(acc telegraf.Accumulator) error {
	s.mu.Lock()
	defer s.mu.Unlock()

	scheme, host, err := getAddressParts(s.Address)
	if err != nil {
		return err
	}
	s.Address = host

	switch scheme {
	case "tcp", "tcp4", "tcp6", "unix", "unixpacket":
		s.isStream = true
	case "udp", "udp4", "udp6", "ip", "ip4", "ip6", "unixgram":
		s.isStream = false
	default:
		return fmt.Errorf("unknown protocol '%s' in '%s'", scheme, s.Address)
	}

	if scheme == "unix" || scheme == "unixpacket" || scheme == "unixgram" {
		os.Remove(s.Address)
	}

	if s.isStream {
		l, err := net.Listen(scheme, s.Address)
		if err != nil {
			return err
		}
		s.Closer = l
		s.tcpListener = l
		s.tlsConfig, err = s.TLSConfig()
		if err != nil {
			return err
		}

		s.wg.Add(1)
		go s.listenStream(acc)
	} else {
		l, err := net.ListenPacket(scheme, s.Address)
		if err != nil {
			return err
		}
		s.Closer = l
		s.udpListener = l

		s.wg.Add(1)
		go s.listenPacket(acc)
	}

	if scheme == "unix" || scheme == "unixpacket" || scheme == "unixgram" {
		s.Closer = unixCloser{path: s.Address, closer: s.Closer}
	}

	return nil
}
729295
func NewLogger() *Logger {
	l := &Logger{}
	l.base.SetPrefix("")
	l.base.SetFlags(log.Lmicroseconds | log.Lshortfile)
	l.SetLevel(LDebug, LInfo, LWarn, LError, LFatal)
	l.SetWriter(os.Stderr)
	return l
}
267720
func (c *Config) Start() func() {
	if c.noProfiles() {
		return func() {}
	}

	var prof struct {
		cpu *os.File
		mem *os.File
	}

	if c.CPU != "" {
		f, err := os.Create(c.CPU)
		if err != nil {
			log.Fatalf("cpuprofile: %v", err)
		}
		prof.cpu = f
		_ = pprof.StartCPUProfile(prof.cpu)
	}

	if c.Memory != "" {
		f, err := os.Create(c.Memory)
		if err != nil {
			log.Fatalf("memprofile: %v", err)
		}
		prof.mem = f
		runtime.MemProfileRate = 4096
	}

	return func() {
		if prof.cpu != nil {
			pprof.StopCPUProfile()
			_ = prof.cpu.Close()
			prof.cpu = nil
		}
		if prof.mem != nil {
			_ = pprof.Lookup("heap").WriteTo(prof.mem, 0)
			_ = prof.mem.Close()
			prof.mem = nil
		}
	}
}
962715
func StartLogging(requestBody, responseBody, timing bool) {
	http.DefaultTransport = &LoggingTransport{&http.Transport{}, requestBody, responseBody, timing}
}
53135
func (h *Holder) logStartup() error {
	time, err := time.Now().MarshalText()
	if err != nil {
		return errors.Wrap(err, "creating timestamp")
	}
	logLine := fmt.Sprintf("%s\t%s\n", time, Version)

	f, err := os.OpenFile(h.Path+"/.startup.log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
	if err != nil {
		return errors.Wrap(err, "opening startup log")
	}

	defer f.Close()

	if _, err = f.WriteString(logLine); err != nil {
		return errors.Wrap(err, "writing startup log")
	}

	return nil
}
850293
func (c *dockerLoggerClient) Start(opts *StartOpts) error {
	req := &proto.StartRequest{
		Endpoint:    opts.Endpoint,
		ContainerId: opts.ContainerID,
		StdoutFifo:  opts.Stdout,
		StderrFifo:  opts.Stderr,
		Tty:         opts.TTY,

		TlsCert: opts.TLSCert,
		TlsKey:  opts.TLSKey,
		TlsCa:   opts.TLSCA,
	}
	_, err := c.client.Start(context.Background(), req)
	return err
}
1310679
func InitLogger() error {
	logFilePath, _ := filepath.Abs(logFile)
	var err error
	logFILE, err = os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND,
		0664)
	if err != nil {
		return fmt.Errorf("Error opening log file: %v", err)
	}

	logrus.SetOutput(io.MultiWriter(logFILE, os.Stdout))
	logrus.SetLevel(logrus.DebugLevel)
	logrus.SetFormatter(&prefix_fmt.TextFormatter{
		ForceColors:     true,
		ForceFormatting: true,
		FullTimestamp:   true,
	})
	//logrus.SetOutput(ansicolor.NewAnsiColorWriter(os.Stdout))
	//logrus.SetOutput(colorable.NewColorableStdout())

	log = logrus.New()
	log.Level = logrus.DebugLevel
	log.Formatter = &prefix_fmt.TextFormatter{
		ForceColors:     true,
		ForceFormatting: true,
		FullTimestamp:   true,
		TimestampFormat: "02 Jan 06 15:04:05.00 -0700",
	}

	//log.Out = colorable.NewColorableStdout()
	//log.Out = colorable.NewNonColorable(io.MultiWriter(logFILE, os.Stdout))
	log.Out = ansicolor.NewAnsiColorWriter(io.MultiWriter(logFILE, os.Stdout))

	log.Debug("rebuilddb logger started.")

	return nil
}