sca_base_module_logger

package module
v0.0.0-...-56f4523 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 11 Imported by: 0

README

SCA Base Module Logger

go get -u github.com/scagogogo/sca-base-module-logger

配置文件中设置:

# 日志相关参数配置
logger:
  # 是否自动初始化日志模块
  auto-init: true
  # 日志的开启级别
  level: info
  # 日志文件的输出目录
  directory: "./logs"
  # 日志开启哪些端
  enable:
    # 是否开启标准输出
    stdout: true
    # 是否开启文件输出
    file: true

对于同一个选项在配置文件和环境变量同时设置的话,以环境变量优先

Documentation

Index

Constants

View Source
const DefaultLoggerDirectory = "./logs"

DefaultLoggerDirectory 默认情况下日志文件夹放在项目根目录下的这个文件夹中

View Source
const ScaLoggerEnableFileEnvName = "SCA_LOGGER_ENABLE_FILE"
View Source
const ScaLoggerEnableStdoutEnvName = "SCA_LOGGER_ENABLE_STDOUT"

Variables

View Source
var ScaAutoInitLoggerEnvName = "SCA_AUTO_INIT_LOGGER"

ScaAutoInitLoggerEnvName 此环境变量控制是否自动初始化logger模块,true自动初始化,false不自动初始化需要手动调用init初始化

View Source
var ScaLoggerDirectoryEnvName = "SCA_LOGGER_DIRECTORY"

ScaLoggerDirectoryEnvName 此环境变量控制日志文件存储的位置,注意优先级如果在配置文件中指定了的话则此处无效

Functions

func DPanic

func DPanic(args ...interface{})

DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicf

func DPanicf(template string, args ...interface{})

DPanicf uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicln

func DPanicln(args ...interface{})

DPanicln uses fmt.Sprintln to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)

func DPanicw

func DPanicw(msg string, keysAndValues ...interface{})

DPanicw logs a message with some additional context. In development, the logger then panics. (See DPanicLevel for details.) The variadic key-value pairs are treated as they are in With.

func Debug

func Debug(args ...interface{})

Debug uses fmt.Sprint to construct and log a message.

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses fmt.Sprintf to log a templated message.

func Debugln

func Debugln(args ...interface{})

Debugln uses fmt.Sprintln to construct and log a message.

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

When debug-level logging is disabled, this is much faster than

s.With(keysAndValues).Debug(msg)

func Error

func Error(args ...interface{})

Error uses fmt.Sprint to construct and log a message.

func Errorf

func Errorf(template string, args ...interface{})

Errorf uses fmt.Sprintf to log a templated message.

func Errorln

func Errorln(args ...interface{})

Errorln uses fmt.Sprintln to construct and log a message.

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func Fatal

func Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func Fatalln

func Fatalln(args ...interface{})

Fatalln uses fmt.Sprintln to construct and log a message, then calls os.Exit.

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With.

func Info

func Info(args ...interface{})

Info uses fmt.Sprint to construct and log a message.

func Infof

func Infof(template string, args ...interface{})

Infof uses fmt.Sprintf to log a templated message.

func Infoln

func Infoln(args ...interface{})

Infoln uses fmt.Sprintln to construct and log a message.

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

func Init

func Init(logDirectory, level string) error

Init 调用初始化日志方法

func Panic

func Panic(args ...interface{})

Panic uses fmt.Sprint to construct and log a message, then panics.

func Panicf

func Panicf(template string, args ...interface{})

Panicf uses fmt.Sprintf to log a templated message, then panics.

func Panicln

func Panicln(args ...interface{})

Panicln uses fmt.Sprintln to construct and log a message, then panics.

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With.

func Sync

func Sync() error

Sync flushes any buffered log entries.

func Warn

func Warn(args ...interface{})

Warn uses fmt.Sprint to construct and log a message.

func Warnf

func Warnf(template string, args ...interface{})

Warnf uses fmt.Sprintf to log a templated message.

func Warnln

func Warnln(args ...interface{})

Warnln uses fmt.Sprintln to construct and log a message.

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw logs a message with some additional context. The variadic key-value pairs are treated as they are in With.

Types

This section is empty.

Directories

Path Synopsis
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.
package rotatelogs is a port of File-RotateLogs from Perl (https://metacpan.org/release/File-RotateLogs), and it allows you to automatically rotate output files when you write to them according to the filename pattern that you can specify.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL