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
e4da27a2
Commit
e4da27a2
authored
10 years ago
by
Henry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented `ipfs log` command
parent
3455846b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
core/commands/log.go
core/commands/log.go
+1
-1
util/log.go
util/log.go
+21
-5
No files found.
core/commands/log.go
View file @
e4da27a2
...
...
@@ -13,6 +13,6 @@ func Log(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Wr
return
err
}
log
.
Info
(
"Changed Log of
'
%q
'
to
'
%q
'
"
,
args
[
0
],
args
[
1
])
log
.
Info
(
"Changed Log
Level
of %q to %q"
,
args
[
0
],
args
[
1
])
return
nil
}
This diff is collapsed.
Click to expand it.
util/log.go
View file @
e4da27a2
...
...
@@ -30,21 +30,21 @@ func SetupLogging() {
logging
.
SetBackend
(
backend
)
logging
.
SetFormatter
(
logging
.
MustStringFormatter
(
LogFormat
))
// always prnt critical and error?
// always pr
i
nt critical and error?
SetAllLoggers
(
logging
.
CRITICAL
)
SetAllLoggers
(
logging
.
ERROR
)
if
logenv
:=
os
.
Getenv
(
"IPFS_LOGGING"
);
logenv
!=
""
{
lvl
,
err
:=
logging
.
LogLevel
(
logenv
)
if
err
!=
nil
{
log
.
Error
(
"
invalid logging level
: %
s
\n
"
,
logenv
)
log
.
Error
(
"
logging.LogLevel() Error
: %
q
\n
"
,
err
)
}
else
{
SetAllLoggers
(
lvl
)
}
}
if
GetenvBool
(
"IPFS_DEBUG"
)
{
log
.
Debug
(
"enabling debug printing"
)
log
.
Info
(
"enabling debug printing"
)
Debug
=
true
SetAllLoggers
(
logging
.
DEBUG
)
}
...
...
@@ -56,7 +56,7 @@ func SetAllLoggers(lvl logging.Level) {
logging
.
SetLevel
(
lvl
,
""
)
for
n
,
log
:=
range
loggers
{
logging
.
SetLevel
(
lvl
,
n
)
log
.
Debug
(
"setting logger: %
s
to %v"
,
n
,
lvl
)
log
.
Notice
(
"setting logger: %
q
to %v"
,
n
,
lvl
)
}
}
...
...
@@ -68,11 +68,27 @@ func Logger(name string) *logging.Logger {
}
// SetLogLevel changes the log level of a specific subsystem
// name=="*" changes all subsystems
func
SetLogLevel
(
name
,
level
string
)
error
{
lvl
,
err
:=
logging
.
LogLevel
(
level
)
if
err
!=
nil
{
return
err
}
// wildcard, change all
if
name
==
"*"
{
SetAllLoggers
(
lvl
)
return
nil
}
// Check if we have a logger by that name
// logging.SetLevel() can't tell us...
_
,
ok
:=
loggers
[
name
]
if
!
ok
{
return
ErrNoSuchLogger
}
return
ErrNotImplemented
logging
.
SetLevel
(
lvl
,
name
)
return
nil
}
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