good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b9d48b4a
Unverified
Commit
b9d48b4a
authored
8 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
log: add support for trace level, exit on critical
parent
ec7f81f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
log/README_ETHEREUM.md
+1
-0
1 addition, 0 deletions
log/README_ETHEREUM.md
log/format.go
+2
-0
2 additions, 0 deletions
log/format.go
log/logger.go
+12
-0
12 additions, 0 deletions
log/logger.go
log/root.go
+6
-0
6 additions, 0 deletions
log/root.go
log/syslog.go
+2
-0
2 additions, 0 deletions
log/syslog.go
with
23 additions
and
0 deletions
log/README_ETHEREUM.md
+
1
−
0
View file @
b9d48b4a
...
@@ -2,3 +2,4 @@ This package is a fork of https://github.com/inconshreveable/log15, with some
...
@@ -2,3 +2,4 @@ This package is a fork of https://github.com/inconshreveable/log15, with some
minor modifications required by the go-ethereum codebase:
minor modifications required by the go-ethereum codebase:
*
Support for log level
`trace`
*
Support for log level
`trace`
*
Modified behavior to exit on
`critical`
failure
This diff is collapsed.
Click to expand it.
log/format.go
+
2
−
0
View file @
b9d48b4a
...
@@ -58,6 +58,8 @@ func TerminalFormat() Format {
...
@@ -58,6 +58,8 @@ func TerminalFormat() Format {
color
=
32
color
=
32
case
LvlDebug
:
case
LvlDebug
:
color
=
36
color
=
36
case
LvlTrace
:
color
=
34
}
}
b
:=
&
bytes
.
Buffer
{}
b
:=
&
bytes
.
Buffer
{}
...
...
This diff is collapsed.
Click to expand it.
log/logger.go
+
12
−
0
View file @
b9d48b4a
...
@@ -2,6 +2,7 @@ package log
...
@@ -2,6 +2,7 @@ package log
import
(
import
(
"fmt"
"fmt"
"os"
"time"
"time"
"github.com/go-stack/stack"
"github.com/go-stack/stack"
...
@@ -20,11 +21,14 @@ const (
...
@@ -20,11 +21,14 @@ const (
LvlWarn
LvlWarn
LvlInfo
LvlInfo
LvlDebug
LvlDebug
LvlTrace
)
)
// Returns the name of a Lvl
// Returns the name of a Lvl
func
(
l
Lvl
)
String
()
string
{
func
(
l
Lvl
)
String
()
string
{
switch
l
{
switch
l
{
case
LvlTrace
:
return
"trce"
case
LvlDebug
:
case
LvlDebug
:
return
"dbug"
return
"dbug"
case
LvlInfo
:
case
LvlInfo
:
...
@@ -44,6 +48,8 @@ func (l Lvl) String() string {
...
@@ -44,6 +48,8 @@ func (l Lvl) String() string {
// Useful for parsing command line args and configuration files.
// Useful for parsing command line args and configuration files.
func
LvlFromString
(
lvlString
string
)
(
Lvl
,
error
)
{
func
LvlFromString
(
lvlString
string
)
(
Lvl
,
error
)
{
switch
lvlString
{
switch
lvlString
{
case
"trace"
,
"trce"
:
return
LvlTrace
,
nil
case
"debug"
,
"dbug"
:
case
"debug"
,
"dbug"
:
return
LvlDebug
,
nil
return
LvlDebug
,
nil
case
"info"
:
case
"info"
:
...
@@ -87,6 +93,7 @@ type Logger interface {
...
@@ -87,6 +93,7 @@ type Logger interface {
SetHandler
(
h
Handler
)
SetHandler
(
h
Handler
)
// Log a message at the given level with context key/value pairs
// Log a message at the given level with context key/value pairs
Trace
(
msg
string
,
ctx
...
interface
{})
Debug
(
msg
string
,
ctx
...
interface
{})
Debug
(
msg
string
,
ctx
...
interface
{})
Info
(
msg
string
,
ctx
...
interface
{})
Info
(
msg
string
,
ctx
...
interface
{})
Warn
(
msg
string
,
ctx
...
interface
{})
Warn
(
msg
string
,
ctx
...
interface
{})
...
@@ -128,6 +135,10 @@ func newContext(prefix []interface{}, suffix []interface{}) []interface{} {
...
@@ -128,6 +135,10 @@ func newContext(prefix []interface{}, suffix []interface{}) []interface{} {
return
newCtx
return
newCtx
}
}
func
(
l
*
logger
)
Trace
(
msg
string
,
ctx
...
interface
{})
{
l
.
write
(
msg
,
LvlTrace
,
ctx
)
}
func
(
l
*
logger
)
Debug
(
msg
string
,
ctx
...
interface
{})
{
func
(
l
*
logger
)
Debug
(
msg
string
,
ctx
...
interface
{})
{
l
.
write
(
msg
,
LvlDebug
,
ctx
)
l
.
write
(
msg
,
LvlDebug
,
ctx
)
}
}
...
@@ -146,6 +157,7 @@ func (l *logger) Error(msg string, ctx ...interface{}) {
...
@@ -146,6 +157,7 @@ func (l *logger) Error(msg string, ctx ...interface{}) {
func
(
l
*
logger
)
Crit
(
msg
string
,
ctx
...
interface
{})
{
func
(
l
*
logger
)
Crit
(
msg
string
,
ctx
...
interface
{})
{
l
.
write
(
msg
,
LvlCrit
,
ctx
)
l
.
write
(
msg
,
LvlCrit
,
ctx
)
os
.
Exit
(
1
)
}
}
func
(
l
*
logger
)
GetHandler
()
Handler
{
func
(
l
*
logger
)
GetHandler
()
Handler
{
...
...
This diff is collapsed.
Click to expand it.
log/root.go
+
6
−
0
View file @
b9d48b4a
...
@@ -41,6 +41,11 @@ func Root() Logger {
...
@@ -41,6 +41,11 @@ func Root() Logger {
// etc.) to keep the call depth the same for all paths to logger.write so
// etc.) to keep the call depth the same for all paths to logger.write so
// runtime.Caller(2) always refers to the call site in client code.
// runtime.Caller(2) always refers to the call site in client code.
// Trace is a convenient alias for Root().Trace
func
Trace
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlTrace
,
ctx
)
}
// Debug is a convenient alias for Root().Debug
// Debug is a convenient alias for Root().Debug
func
Debug
(
msg
string
,
ctx
...
interface
{})
{
func
Debug
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlDebug
,
ctx
)
root
.
write
(
msg
,
LvlDebug
,
ctx
)
...
@@ -64,4 +69,5 @@ func Error(msg string, ctx ...interface{}) {
...
@@ -64,4 +69,5 @@ func Error(msg string, ctx ...interface{}) {
// Crit is a convenient alias for Root().Crit
// Crit is a convenient alias for Root().Crit
func
Crit
(
msg
string
,
ctx
...
interface
{})
{
func
Crit
(
msg
string
,
ctx
...
interface
{})
{
root
.
write
(
msg
,
LvlCrit
,
ctx
)
root
.
write
(
msg
,
LvlCrit
,
ctx
)
os
.
Exit
(
1
)
}
}
This diff is collapsed.
Click to expand it.
log/syslog.go
+
2
−
0
View file @
b9d48b4a
...
@@ -38,6 +38,8 @@ func sharedSyslog(fmtr Format, sysWr *syslog.Writer, err error) (Handler, error)
...
@@ -38,6 +38,8 @@ func sharedSyslog(fmtr Format, sysWr *syslog.Writer, err error) (Handler, error)
syslogFn
=
sysWr
.
Info
syslogFn
=
sysWr
.
Info
case
LvlDebug
:
case
LvlDebug
:
syslogFn
=
sysWr
.
Debug
syslogFn
=
sysWr
.
Debug
case
LvlTrace
:
syslogFn
=
func
(
m
string
)
error
{
return
nil
}
// There's no syslog level for trace
}
}
s
:=
strings
.
TrimSpace
(
string
(
fmtr
.
Format
(
r
)))
s
:=
strings
.
TrimSpace
(
string
(
fmtr
.
Format
(
r
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment