Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigBaseLogger(pluginName string, options *Options) error
- func ConfigDefaultBaseLogger(pluginName string) error
- func ConfigDefaultDetectLogger(pluginName string) error
- func ConfigDefaultNetworkLogger(pluginName string) error
- func ConfigDefaultStatLogger(pluginName string) error
- func ConfigDefaultStatReportLogger(pluginName string) error
- func ConfigDetectLogger(pluginName string, options *Options) error
- func ConfigNetworkLogger(pluginName string, options *Options) error
- func ConfigStatLogger(pluginName string, options *Options) error
- func ConfigStatReportLogger(pluginName string, options *Options) error
- func RegisterLoggerCreator(name string, creator loggerCreator)
- func SetBaseLogger(logger Logger)
- func SetDetectLogger(logger Logger)
- func SetNetworkLogger(logger Logger)
- func SetStatLogger(logger Logger)
- func SetStatReportLogger(logger Logger)
- func VerifyLogLevel(level int) error
- type DirLogger
- type Logger
- type Options
Constants ¶
View Source
const ( //默认logger DefaultLogger = LoggerZap //默认基础日志级别 DefaultBaseLogLevel = InfoLog //默认统计日志级别 DefaultStatLogLevel = InfoLog //默认探测日志级别 DefaultDetectLogLevel = InfoLog //默认统计上报日志级别 DefaultStatReportLogLevel = InfoLog //默认网络交互日志级别 DefaultNetworkLogLevel = InfoLog )
View Source
const ( //默认直接错误输出路径 DefaultErrorOutputPath = "stderr" //默认滚动日志保留时间 DefaultRotationMaxAge = 30 //默认单个日志最大占用空间 DefaultRotationMaxSize = 50 //默认最大滚动备份 DefaultRotationMaxBackups = 5 //默认日志根目录 DefaultLogRotationRootDir = "./polaris/log" //默认基础日志滚动文件 DefaultBaseLogRotationPath = "/base/polaris.log" //默认统计日志滚动文件 DefaultStatLogRotationPath = "/stat/polaris-stat.log" //默认统计上报日志滚动文件 DefaultStatReportLogRotationPath = "/statReport/polaris-statReport.log" //默认探测日志滚动文件 DefaultDetectLogRotationPath = "/detect/polaris-detect.log" //默认网络交互日志滚动文件 DefaultNetworkLogRotationPath = "/network/polaris-network.log" //默认基础日志滚动文件全路径 DefaultBaseLogRotationFile = DefaultLogRotationRootDir + DefaultBaseLogRotationPath //默认统计日志滚动文件全路径 DefaultStatLogRotationFile = DefaultLogRotationRootDir + DefaultStatLogRotationPath //默认统计上报日志滚动文件全路径 DefaultStatReportLogRotationFile = DefaultLogRotationRootDir + DefaultStatReportLogRotationPath //默认探测日志滚动文件全路径 DefaultDetectLogRotationFile = DefaultLogRotationRootDir + DefaultDetectLogRotationPath //默认网络交互日志滚动文件全路径 DefaultNetworkLogRotationFile = DefaultLogRotationRootDir + DefaultNetworkLogRotationPath )
View Source
const ( //跟踪级别 TraceLog int = iota //调试级别 DebugLog //一般日志级别 InfoLog //警告日志级别 WarnLog //错误日志级别 ErrorLog //致命级别 FatalLog //当要禁止日志的时候,可以设置此级别 NoneLog )
View Source
const ( //基础日志对象 BaseLogger = iota //统计日志对象 StatLogger //统计日志上报对象,记录上报日志的情况 StatReportLogger //探测日志对象 DetectLogger //与系统服务进行网络交互的相关日志 NetworkLogger //日志对象总量 MaxLogger )
日志类型
View Source
const (
//zap实现的logger
LoggerZap = "zaplog"
)
Variables ¶
View Source
var SeverityName = []string{ TraceLog: "TRACE", DebugLog: "DEBUG", InfoLog: "INFO", WarnLog: "WARNING", ErrorLog: "ERROR", FatalLog: "FATAL", }
severityName contains the string representation of each severity.
Functions ¶
func ConfigDefaultNetworkLogger ¶
配置默认的网络交互日志器
func ConfigDefaultStatReportLogger ¶
配置默认的统计上报日志器
func ConfigDetectLogger ¶
配置探测日志器
func ConfigNetworkLogger ¶
配置网络交互日志器
func ConfigStatReportLogger ¶
func RegisterLoggerCreator ¶
func RegisterLoggerCreator(name string, creator loggerCreator)
注册Logger插件
Types ¶
type Logger ¶
type Logger interface { //打印trace级别的日志 Tracef(format string, args ...interface{}) //打印debug级别的日志 Debugf(format string, args ...interface{}) //打印info级别的日志 Infof(format string, args ...interface{}) //打印warn级别的日志 Warnf(format string, args ...interface{}) //打印error级别的日志 Errorf(format string, args ...interface{}) //打印fatalf级别的日志 Fatalf(format string, args ...interface{}) //判断当前级别是否满足日志打印的最低级别 IsLevelEnabled(l int) bool //动态设置日志打印级别 SetLogLevel(l int) error }
*
- @brief 日志对象,封装了日志打印的接口逻辑
type Options ¶
type Options struct { // OutputPaths is a list of file system paths to write the log data to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stdout. OutputPaths []string // ErrorOutputPaths is a list of file system paths to write logger errors to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stderr. ErrorOutputPaths []string // RotateOutputPath is the path to a rotating log file. This file should // be automatically rotated over time, based on the rotation parameters such // as RotationMaxSize and RotationMaxAge. The default is to not rotate. // // This path is used as a foundational path. This is where log output is normally // saved. When a rotation needs to take place because the file got too big or too // old, then the file is renamed by appending a timestamp to the name. Such renamed // files are called backups. Once a backup has been created, // output resumes to this path. RotateOutputPath string // RotationMaxSize is the maximum size in megabytes of a log file before it gets // rotated. It defaults to 100 megabytes. RotationMaxSize int // RotationMaxAge is the maximum number of days to retain old log files based on the // timestamp encoded in their filename. Note that a day is defined as 24 // hours and may not exactly correspond to calendar days due to daylight // savings, leap seconds, etc. The default is to remove log files // older than 30 days. RotationMaxAge int // RotationMaxBackups is the maximum number of old log files to retain. The default // is to retain at most 1000 logs. RotationMaxBackups int //The min log level that actual log output LogLevel int }
Options defines the set of options for component logging package.
func CreateDefaultLoggerOptions ¶
配置默认的日志插件
Click to show internal directories.
Click to hide internal directories.