Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
张蕾
Geth-Modification
Commits
a36c68f1
Unverified
Commit
a36c68f1
authored
Feb 22, 2023
by
Nate Armstrong
Committed by
GitHub
Feb 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: improve documentation (#26753)
Add usage examples
parent
f6a7cc68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
1 deletion
+95
-1
logger.go
log/logger.go
+47
-1
root.go
log/root.go
+48
-0
No files found.
log/logger.go
View file @
a36c68f1
...
...
@@ -116,12 +116,58 @@ type Logger interface {
// SetHandler updates the logger to write records to the specified handler.
SetHandler
(
h
Handler
)
// Log a message at the given level with context key/value pairs
// Log a message at the trace level with context key/value pairs
//
// # Usage
//
// log.Trace("msg")
// log.Trace("msg", "key1", val1)
// log.Trace("msg", "key1", val1, "key2", val2)
Trace
(
msg
string
,
ctx
...
interface
{})
// Log a message at the debug level with context key/value pairs
//
// # Usage Examples
//
// log.Debug("msg")
// log.Debug("msg", "key1", val1)
// log.Debug("msg", "key1", val1, "key2", val2)
Debug
(
msg
string
,
ctx
...
interface
{})
// Log a message at the info level with context key/value pairs
//
// # Usage Examples
//
// log.Info("msg")
// log.Info("msg", "key1", val1)
// log.Info("msg", "key1", val1, "key2", val2)
Info
(
msg
string
,
ctx
...
interface
{})
// Log a message at the warn level with context key/value pairs
//
// # Usage Examples
//
// log.Warn("msg")
// log.Warn("msg", "key1", val1)
// log.Warn("msg", "key1", val1, "key2", val2)
Warn
(
msg
string
,
ctx
...
interface
{})
// Log a message at the error level with context key/value pairs
//
// # Usage Examples
//
// log.Error("msg")
// log.Error("msg", "key1", val1)
// log.Error("msg", "key1", val1, "key2", val2)
Error
(
msg
string
,
ctx
...
interface
{})
// Log a message at the crit level with context key/value pairs, and then exit.
//
// # Usage Examples
//
// log.Crit("msg")
// log.Crit("msg", "key1", val1)
// log.Crit("msg", "key1", val1, "key2", val2)
Crit
(
msg
string
,
ctx
...
interface
{})
}
...
...
log/root.go
View file @
a36c68f1
...
...
@@ -30,31 +30,79 @@ func Root() Logger {
// runtime.Caller(2) always refers to the call site in client code.
// Trace is a convenient alias for Root().Trace
//
// Log a message at the trace level with context key/value pairs
//
// # Usage
//
// log.Trace("msg")
// log.Trace("msg", "key1", val1)
// log.Trace("msg", "key1", val1, "key2", val2)
func
Trace
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlTrace
,
ctx
,
skipLevel
)
}
// Debug is a convenient alias for Root().Debug
//
// Log a message at the debug level with context key/value pairs
//
// # Usage Examples
//
// log.Debug("msg")
// log.Debug("msg", "key1", val1)
// log.Debug("msg", "key1", val1, "key2", val2)
func
Debug
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlDebug
,
ctx
,
skipLevel
)
}
// Info is a convenient alias for Root().Info
//
// Log a message at the info level with context key/value pairs
//
// # Usage Examples
//
// log.Info("msg")
// log.Info("msg", "key1", val1)
// log.Info("msg", "key1", val1, "key2", val2)
func
Info
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlInfo
,
ctx
,
skipLevel
)
}
// Warn is a convenient alias for Root().Warn
//
// Log a message at the warn level with context key/value pairs
//
// # Usage Examples
//
// log.Warn("msg")
// log.Warn("msg", "key1", val1)
// log.Warn("msg", "key1", val1, "key2", val2)
func
Warn
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlWarn
,
ctx
,
skipLevel
)
}
// Error is a convenient alias for Root().Error
//
// Log a message at the error level with context key/value pairs
//
// # Usage Examples
//
// log.Error("msg")
// log.Error("msg", "key1", val1)
// log.Error("msg", "key1", val1, "key2", val2)
func
Error
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlError
,
ctx
,
skipLevel
)
}
// Crit is a convenient alias for Root().Crit
//
// Log a message at the crit level with context key/value pairs, and then exit.
//
// # Usage Examples
//
// log.Crit("msg")
// log.Crit("msg", "key1", val1)
// log.Crit("msg", "key1", val1, "key2", val2)
func
Crit
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlCrit
,
ctx
,
skipLevel
)
os
.
Exit
(
1
)
...
...
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