Documentation ¶
Overview ¶
Copyright 2020 Go-Ceres Author https://github.com/go-ceres/go-ceres
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Go-Ceres Author https://github.com/go-ceres/go-ceres
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Go-Ceres Author https://github.com/go-ceres/go-ceres
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2020 Go-Ceres Author https://github.com/go-ceres/go-ceres
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func DPanic(args ...interface{})
- func DPanicd(msg string, fields ...Field)
- func DPanicf(template string, args ...interface{})
- func DPanicw(msg string, keysAndValues ...interface{})
- func Debug(args ...interface{})
- func Debugd(msg string, fields ...Field)
- func Debugf(template string, args ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(args ...interface{})
- func Errord(msg string, fields ...Field)
- func Errorf(template string, args ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func FieldAid(aid string) zap.Field
- func FieldAny(key string, val interface{}) zap.Field
- func FieldCode(code interface{}) zap.Field
- func FieldErr(err error) zap.Field
- func FieldHost(host string) zap.Field
- func FieldIp(ip string) zap.Field
- func FieldMod(mod string) zap.Field
- func FieldString(key, val string) zap.Field
- func FieldTid(tid string) zap.Field
- func FieldValue(value interface{}) zap.Field
- func Info(args ...interface{})
- func Infod(msg string, fields ...Field)
- func Infof(template string, args ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func Panic(args ...interface{})
- func Panicd(msg string, fields ...Field)
- func Panicf(template string, args ...interface{})
- func Panicw(msg string, keysAndValues ...interface{})
- func Warn(args ...interface{})
- func Warnd(msg string, fields ...Field)
- func Warnf(template string, args ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type Config
- type Field
- type Func
- type Level
- type Logger
- type Rotate
- type RotateConfig
Constants ¶
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zap.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zap.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zap.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-Level logs. ErrorLevel = zap.ErrorLevel // PanicLevel logs a message, then panics. PanicLevel = zap.PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = zap.FatalLevel )
Variables ¶
var ( DefaultLogger = Config{ Stdout: true, Debug: true, AddCaller: true, CallerSkip: 2, Rotate: false, RotateConfig: NewDefaultRotateConfig(), }.Build() FrameLogger = Config{ Debug: true, Stdout: true, AddCaller: true, CallerSkip: 2, }.Build() )
var ( // String ... String = zap.String // Any ... Any = zap.Any // Int64 ... Int64 = zap.Int64 // Int ... Int = zap.Int // Int32 ... Int32 = zap.Int32 // Uint ... Uint = zap.Uint // Duration ... Duration = zap.Duration // Durationp ... Durationp = zap.Durationp // Object ... Object = zap.Object // Namespace ... Namespace = zap.Namespace // Reflect ... Reflect = zap.Reflect // Skip ... Skip = zap.Skip() // ByteString ... ByteString = zap.ByteString )
Functions ¶
Types ¶
type Config ¶
type Config struct { Debug bool // 是否开启debug模式,默认false Level string // 日志等级 Stdout bool // 是否在控制台打印,默认,true Rotate bool // 是否文件日志输出 Fields []zap.Field // 初始化字段 AddCaller bool // 是否打印调用者信息,默认,true CallerSkip int // 表示输出当前栈帧,默认,1 Core zapcore.Core *RotateConfig // 文件日志输出配置 // contains filtered or unexported fields }
type Logger ¶
type Logger interface { SetLevel(level Level) AddCallerSkip(i int) Logger With(...Field) Logger // Sugar Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) DPanic(args ...interface{}) Panic(args ...interface{}) // Sugar f Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) DPanicf(template string, args ...interface{}) Panicf(template string, args ...interface{}) // Sugar w Debugw(msg string, keysAndValues ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Errorw(msg string, keysAndValues ...interface{}) DPanicw(msg string, keysAndValues ...interface{}) Panicw(msg string, keysAndValues ...interface{}) // DeSugar Debugd(msg string, fields ...Field) Infod(msg string, fields ...Field) Warnd(msg string, fields ...Field) Errord(msg string, fields ...Field) DPanicd(msg string, fields ...Field) Panicd(msg string, fields ...Field) }
type RotateConfig ¶
type RotateConfig struct { Name string // Name 日志文件路径。默认为空,表示关闭,仅输出到终端 MaxSize int // MaxSize 按照日志文件大小对文件进行滚动切分。默认为0,表示关闭滚动切分特性 MaxAge int // MaxAge 按照切分的文件有效期清理切分文件,当滚动切分特性开启时有效。默认为0,表示不备份,切分则删除 MaxBackups int // MaxBackups 文件保存的最大数量,默认值为10 Interval time.Duration // Interval 日志轮转的时间,默认当前条件无效 LocalTime bool // LocalTime LocalTime确定用于格式化中的时间戳的时间,备份文件是计算机的本地时间 Compress bool // Compress 是否使用gzip压缩日志文件,默认不压缩 }
日志分割配置信息
func NewDefaultRotateConfig ¶
func NewDefaultRotateConfig() *RotateConfig