// IsLogging tests whether the context is configured to log at the specified
// level.
//
// Individual Logger implementations are supposed to call this function when
// deciding whether to log the message.
165047
func IsLogging(c context.Context, l Level) bool {
	return l >= GetLevel(c)
}
894193
func FromContext(ctx context.Context) (Logger, bool) {
	l, ok := ctx.Value(loggerKey).(Logger)
	return l, ok
}
579189
func FromContext(ctx context.Context) Logger {
	logger, ok := ctx.Value("termlog").(Logger)
	if !ok {
		l := NewLog()
		l.Quiet()
		return l
	}
	return logger
}
890320
func (c *Context) Log() *log.Entry {
	fields := log.Fields{"service": c.ServiceName}

	if Config.Debug {
		pc := make([]uintptr, 10)
		runtime.Callers(2, pc)
		f := runtime.FuncForPC(pc[0])
		fields["file"], fields["line"] = f.FileLine(pc[0])
		fields["func"] = f.Name()
	}

	if c.User.ID > 0 {
		fields["user"] = c.User.ID
	}
	if c.Chat.ID != 0 {
		fields["chat"] = c.Chat.ID
	}
	if c.Message != nil {
		fields["msg"] = c.Message.GetTextHash()
	}

	if c.ChosenInlineResult != nil {
		fields["chosenresult"] = c.ChosenInlineResult
	}

	if c.InlineQuery != nil {
		fields["inlinequery"] = c.InlineQuery
	}

	if c.Callback != nil {
		fields["callback"] = c.Callback.Data
		fields["callback_id"] = c.Callback.ID

		if c.Callback.Message.MsgID > 0 {
			fields["callback_msgid"] = c.Callback.Message.MsgID
		} else {
			fields["callback_inlinemsgid"] = c.Callback.Message.InlineMsgID
		}

	}

	if c.gin != nil {
		fields["url"] = c.gin.Request.Method + " " + c.gin.Request.URL.String()
		fields["ip"] = c.gin.Request.RemoteAddr
	}

	fields["domain"] = c.ServiceBaseURL.Host

	return log.WithFields(fields)
}
654957
func (log Logger) Log(lvl level, source, message string) {
	log.intLogNamef(logName(lvl), lvl, message)
}
110886
func (l *LogAction) Log(level, format string, args ...interface{}) predicate.BoolPredicate {
	return func() bool {
		ilevel, err := log.ParseLevel(level)
		if err != nil {
			ilevel = log.DebugLevel
		}
		var writer io.Writer
		if l.writer != nil {
			writer = l.writer
		} else {
			writer = log.StandardLogger().WriterLevel(ilevel)
		}
		writer.Write([]byte(fmt.Sprintf(format, args...)))
		return true
	}
}
1127317
func initContextLogger(ctx context.Context) context.Context {
	logger := newLoggerStruct()

	output := sharedutils.EnvOrDefault("LOG_OUTPUT", "syslog")
	if output == "syslog" {
		syslogBackend, err := log.SyslogHandler(syslog.LOG_INFO, ProcessName, log.LogfmtFormat())
		sharedutils.CheckError(err)
		logger.SetHandler(syslogBackend)
	} else {
		stdoutBackend := log.StreamHandler(os.Stdout, log.LogfmtFormat())
		logger.SetHandler(stdoutBackend)
	}

	logger.processPid = strconv.Itoa(os.Getpid())

	ctx = context.WithValue(ctx, LoggerKey, logger)

	level := sharedutils.EnvOrDefault("LOG_LEVEL", "")
	if level != "" {
		logger.logger.Info("Setting log level to " + level)
		ctx = LoggerSetLevel(ctx, level)
	}

	return ctx
}
960511
func newLogger(c *Context) (log15.Logger, error) {
	lvl := c.String(FlagLogLevel)
	l := log15.New()
	log.Println(fmt.Sprintf("Using log level %s", lvl))
	v, err := log15.LvlFromString(lvl)
	if err != nil {
		return l, err
	}
	h := log15.LvlFilterHandler(v, log15.StreamHandler(os.Stdout, log15.LogfmtFormat()))
	if lvl == "debug" {
		h = log15.CallerFileHandler(h)
	}
	l.SetHandler(log15.LazyHandler(h))
	return l, err
}
1048884
func (fw *Framework) SetupLogging(debug bool) (err error) {
	fw.log = log.New()

	fw.log.Out = os.Stdout

	if fw.Config.LogFile != "" {
		fw.log.Formatter = &log.JSONFormatter{}

		file, err := os.OpenFile(fw.Config.LogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666)
		if err != nil {
			return fmt.Errorf("Could not set up logging: %s", err)
		}

		fw.log.Out = file
	}

	switch fw.Config.LogLevel {
	case "debug":
		fw.log.SetLevel(log.DebugLevel)
	case "info":
		fw.log.SetLevel(log.InfoLevel)
	case "warn":
		fw.log.SetLevel(log.WarnLevel)
	case "error":
		fw.log.SetLevel(log.ErrorLevel)
	case "fatal":
		fw.log.SetLevel(log.FatalLevel)
	default:
		fw.log.SetLevel(log.WarnLevel)
	}

	if debug {
		fw.log.SetLevel(log.DebugLevel)
	}

	log.SetFormatter(fw.log.Formatter)
	log.SetLevel(fw.log.Level)
	log.SetOutput(fw.log.Out)

	return
}
457914
func SetupLoggingForLevels(token, env string, levels []logrus.Level) {
	setupLogging(token, env, levels)
}
624420
func (logger *Logger) log(logClass LogClass, message string) {
	ld := logger.newLineData(logClass, message)
	b := &backgroundLineLogger{
		lineData: *ld,
		logger:   logger,
	}
	transitChannel <- b
}
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
}
561100
func (s *ServicedStorage) initializeLogging() {
	log.SetOutput(os.Stderr)
	level := log.WarnLevel + log.Level(len(App.Options.Verbose))
	log.SetLevel(level)

	// Include glog output if verbosity is enabled
	if len(App.Options.Verbose) > 0 {
		glog.SetToStderr(true)
		glog.SetVerbosity(len(App.Options.Verbose))
	}
}
534876
func (s *GetTrailStatusOutput) SetIsLogging(v bool) *GetTrailStatusOutput {
	s.IsLogging = &v
	return s
}
769769
func IsEnabledForLogLevel(logLevel string) bool {
	lvl, _ := logging.LogLevel(logLevel)
	return chaincodeLogger.IsEnabledFor(lvl)
}
426040
func (c *Container) IsRunning(ctx context.Context) bool {
	return c.container.State.Running
}
531563
func (l *Logger) Log(format string, args ...interface{}) {
	l.log(1, false, format, args...)
}