Documentation ¶
Overview ¶
Copyright 2024 The seacraft Authors *
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 2024 The seacraft Authors *
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 2024 The seacraft Authors *
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.
Package log is a log package used by TKE team.
Copyright 2024 The seacraft Authors *
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 2024 The seacraft Authors *
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 ¶
- Variables
- func CheckIntLevel(level int32) bool
- func Debug(msg string, fields ...Field)
- func Debugf(format string, v ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(msg string, fields ...Field)
- func Errorf(format string, v ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(msg string, fields ...Field)
- func Fatalf(format string, v ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func Flush()
- func GetLogger() *zapLogger
- func Info(msg string, fields ...Field)
- func Infof(format string, v ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func Init(opts *Options)
- func Panic(msg string, fields ...Field)
- func Panicf(format string, v ...interface{})
- func Panicw(msg string, keysAndValues ...interface{})
- func StdErrLogger() *log.Logger
- func StdInfoLogger() *log.Logger
- func Warn(msg string, fields ...Field)
- func Warnf(format string, v ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- func ZapLogger() *zap.Logger
- type Field
- type InfoLogger
- type Level
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zapcore.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zapcore.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zapcore.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = zapcore.ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel = zapcore.DPanicLevel // PanicLevel logs a message, then panics. PanicLevel = zapcore.PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = zapcore.FatalLevel )
var ( Any = zap.Any Array = zap.Array Object = zap.Object Binary = zap.Binary Bool = zap.Bool Bools = zap.Bools ByteString = zap.ByteString ByteStrings = zap.ByteStrings Complex64 = zap.Complex64 Complex64s = zap.Complex64s Complex128 = zap.Complex128 Complex128s = zap.Complex128s Duration = zap.Duration Durations = zap.Durations Err = zap.Error Errors = zap.Errors Float32 = zap.Float32 Float32s = zap.Float32s Float64 = zap.Float64 Float64s = zap.Float64s Int = zap.Int Ints = zap.Ints Int8 = zap.Int8 Int8s = zap.Int8s Int16 = zap.Int16 Int16s = zap.Int16s Int32 = zap.Int32 Int32s = zap.Int32s Int64 = zap.Int64 Int64s = zap.Int64s Namespace = zap.Namespace Reflect = zap.Reflect Stack = zap.Stack String = zap.String Stringer = zap.Stringer Strings = zap.Strings Time = zap.Time Times = zap.Times Uint = zap.Uint Uints = zap.Uints Uint8 = zap.Uint8 Uint8s = zap.Uint8s Uint16 = zap.Uint16 Uint16s = zap.Uint16s Uint32 = zap.Uint32 Uint32s = zap.Uint32s Uint64 = zap.Uint64 Uint64s = zap.Uint64s Uintptr = zap.Uintptr Uintptrs = zap.Uintptrs )
Alias for zap type functions.
Functions ¶
func CheckIntLevel ¶
CheckIntLevel used for other log wrapper such as klog which return if logging a message at the specified level is enabled.
func Debugw ¶
func Debugw(msg string, keysAndValues ...interface{})
Debugw method output debug level log.
func Errorw ¶
func Errorw(msg string, keysAndValues ...interface{})
Errorw method output error level log.
func Fatalw ¶
func Fatalw(msg string, keysAndValues ...interface{})
Fatalw method output Fatalw level log.
func Flush ¶
func Flush()
Flush calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.
func Infow ¶
func Infow(msg string, keysAndValues ...interface{})
Infow method output info level log.
func Init ¶
func Init(opts *Options)
Init initializes logger by opts which can custmoized by command arguments.
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf method output panic level log and shutdown application.
func Panicw ¶
func Panicw(msg string, keysAndValues ...interface{})
Panicw method output panic level log.
func StdErrLogger ¶
StdErrLogger returns logger of standard library which writes to supplied zap logger at error level.
func StdInfoLogger ¶
StdInfoLogger returns logger of standard library which writes to supplied zap logger at info level.
Types ¶
type InfoLogger ¶
type InfoLogger interface { // Info logs a non-error message with the given key/value pairs as context. // // The msg argument should be used to add some constant description to // the log line. The key/value pairs can then be used to add additional // variable information. The key/value pairs should alternate string // keys and arbitrary values. Info(msg string, keysAndValues ...interface{}) Infof(format string, args ...interface{}) // Enabled tests whether this InfoLogger is enabled. For example, // commandline flags might be used to set the logging verbosity and disable // some info logs. Enabled() bool }
InfoLogger represents the ability to log non-error messages, at a particular verbosity.
type Logger ¶
type Logger interface { // All Loggers implement InfoLogger. Calling InfoLogger methods directly on // a Logger value is equivalent to calling them on a V(0) InfoLogger. For // example, logger.Info() produces the same result as logger.V(0).Info. InfoLogger // Error logs an error, with the given message and key/value pairs as context. // It functions similarly to calling Info with the "error" named value, but may // have unique behavior, and should be preferred for logging errors (see the // package documentations for more information). // // The msg field should be used to add context to any underlying error, // while the err field should be used to attach the actual error that // triggered this log line, if present. Error(err error, msg string, keysAndValues ...interface{}) Errorf(format string, args ...interface{}) // V returns an InfoLogger value for a specific verbosity level. A higher // verbosity level means a log message is less important. It's illegal to // pass a log level less than zero. V(level int) InfoLogger Write(p []byte) (n int, err error) // WithValues adds some key-value pairs of context to a logger. // See Info for documentation on how key/value pairs work. WithValues(keysAndValues ...interface{}) Logger // WithName adds a new element to the logger's name. // Successive calls with WithName continue to append // suffixes to the logger's name. It's strongly recommended // that name segments contain only letters, digits, and hyphens // (see the package documentation for more information). WithName(name string) Logger // WithContext returns a copy of context in which the log value is set. WithContext(ctx context.Context) context.Context // Flush calls the underlying Core's Sync method, flushing any buffered // log entries. Applications should take care to call Sync before exiting. Flush() }
Logger represents the ability to log messages, both errors and not.
func FromContext ¶
FromContext returns the value of the log key on the ctx.
func WithName ¶
WithName adds a new path segment to the logger's name. Segments are joined by periods. By default, Loggers are unnamed.
func WithValues ¶
func WithValues(keysAndValues ...interface{}) Logger
WithValues creates a child logger and adds adds Zap fields to it.
type Options ¶
type Options struct { Level string `json:"level" mapstructure:"level"` Format string `json:"format" mapstructure:"format"` EnableColor bool `json:"enable-color" mapstructure:"enable-color"` EnableCaller bool `json:"enable-caller" mapstructure:"enable-caller"` OutputPaths []string `json:"output-paths" mapstructure:"output-paths"` ErrorOutputPaths []string `json:"error-output-paths" mapstructure:"error-output-paths"` }
Options contains configuration items related to log.
func GetOptions ¶
func GetOptions() *Options
func NewOptions ¶
func NewOptions() *Options
NewOptions creates a Options object with default parameters.
Directories ¶
Path | Synopsis |
---|---|
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
example
module
|
|
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
|
* Copyright 2024 The seacraft Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. |