Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
ffe2bdce
Commit
ffe2bdce
authored
10 years ago
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init SetupLoggers
this is useful so that loggers are all setup during tests
parent
8e9b10f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+1
-1
util/util.go
util/util.go
+11
-5
No files found.
cmd/ipfs/ipfs.go
View file @
ffe2bdce
...
...
@@ -80,7 +80,7 @@ func main() {
u
.
Debug
=
false
// setup logging
u
.
SetupLogging
()
//
u.SetupLogging()
done in an init() block now.
// if debugging, setup profiling.
if
u
.
Debug
{
...
...
This diff is collapsed.
Click to expand it.
util/util.go
View file @
ffe2bdce
...
...
@@ -17,8 +17,12 @@ import (
logging
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
)
func
init
()
{
SetupLogging
()
}
// LogFormat is the format used for our logger.
var
LogFormat
=
"%{color}%{time:01-02 15:04:05.9999} %{shortfile} %{level}: %{color:reset}%{message}"
var
LogFormat
=
"%{color}%{time:
2006-
01-02 15:04:05.9999
99
} %{shortfile} %{level}: %{color:reset}%{message}"
// Debug is a global flag for debugging.
var
Debug
bool
...
...
@@ -122,12 +126,14 @@ func DOut(format string, a ...interface{}) {
}
}
var
loggers
=
[
]
string
{}
var
loggers
=
map
[
string
]
*
logging
.
Logger
{}
// SetupLogging will initialize the logger backend and set the flags.
func
SetupLogging
()
{
backend
:=
logging
.
NewLogBackend
(
os
.
Stderr
,
""
,
0
)
logging
.
SetBackend
(
backend
)
logging
.
SetFormatter
(
logging
.
MustStringFormatter
(
LogFormat
))
/*
if Debug {
logging.SetLevel(logging.DEBUG, "")
...
...
@@ -135,10 +141,10 @@ func SetupLogging() {
logging.SetLevel(logging.ERROR, "")
}
*/
logging
.
SetFormatter
(
logging
.
MustStringFormatter
(
LogFormat
))
for
_
,
n
:=
range
loggers
{
for
n
,
log
:=
range
loggers
{
logging
.
SetLevel
(
logging
.
ERROR
,
n
)
log
.
Error
(
"setting logger: %s to %v
\n
"
,
n
,
logging
.
ERROR
)
}
}
...
...
@@ -146,7 +152,7 @@ func SetupLogging() {
func
Logger
(
name
string
)
*
logging
.
Logger
{
log
:=
logging
.
MustGetLogger
(
name
)
// logging.SetLevel(lvl, name) // can't set level here.
loggers
=
append
(
loggers
,
name
)
loggers
[
name
]
=
log
return
log
}
...
...
This diff is collapsed.
Click to expand it.
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