Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
3db78c9b
Commit
3db78c9b
authored
Oct 29, 2021
by
wei.xuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logger
parent
2403c0eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
31 deletions
+6
-31
logger.go
logger.go
+6
-31
No files found.
logger.go
View file @
3db78c9b
...
...
@@ -38,24 +38,13 @@ type Logger interface {
type
LoggerLevel
int8
const
(
// DebugLevel logs are typically voluminous, and are usually disabled in
// production.
LoggerLevelDebug
=
LoggerLevel
(
zapcore
.
DebugLevel
)
// InfoLevel is the default logging priority.
LoggerLevelInfo
=
LoggerLevel
(
zapcore
.
InfoLevel
)
// WarnLevel logs are more important than Infof, but don't need individual
// human review.
LoggerLevelWarn
=
LoggerLevel
(
zapcore
.
WarnLevel
)
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-level logs.
LoggerLevelError
=
LoggerLevel
(
zapcore
.
ErrorLevel
)
// DPanicLevel logs are particularly important errors. In development the
// logger panics after writing the message.
LoggerLevelDebug
=
LoggerLevel
(
zapcore
.
DebugLevel
)
LoggerLevelInfo
=
LoggerLevel
(
zapcore
.
InfoLevel
)
LoggerLevelWarn
=
LoggerLevel
(
zapcore
.
WarnLevel
)
LoggerLevelError
=
LoggerLevel
(
zapcore
.
ErrorLevel
)
LoggerLevelDPanic
=
LoggerLevel
(
zapcore
.
DPanicLevel
)
// PanicLevel logs a message, then panics.
LoggerLevelPanic
=
LoggerLevel
(
zapcore
.
PanicLevel
)
// FatalLevel logs a message, then calls os.Exit(1).
LoggerLevelFatal
=
LoggerLevel
(
zapcore
.
FatalLevel
)
LoggerLevelPanic
=
LoggerLevel
(
zapcore
.
PanicLevel
)
LoggerLevelFatal
=
LoggerLevel
(
zapcore
.
FatalLevel
)
)
var
(
...
...
@@ -81,20 +70,6 @@ func init() {
zapLoggerConfig
.
EncoderConfig
=
zapLoggerEncoderConfig
zapLogger
,
_
=
zapLoggerConfig
.
Build
()
log
=
zapLogger
.
Sugar
()
// todo: flushes buffer when redirect log to file.
// var exitSignal = make(chan os.Signal)
// signal.Notify(exitSignal, syscall.SIGTERM, syscall.SIGINT)
// go func() {
// <-exitSignal
// // Sync calls the underlying Core's Sync method, flushing any buffered log
// // entries. Applications should take care to call Sync before exiting.
// err := zapLogger.Sync() // flushes buffer, if any
// if err != nil {
// fmt.Printf("zapLogger sync err: %+v", perrors.WithStack(err))
// }
// os.Exit(0)
// }()
}
// SetLogger customize yourself logger.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment