1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-18 09:17:49 +08:00

transitioned ipfs2 -> ipfs

This commit is contained in:
Juan Batiz-Benet
2014-11-18 02:39:48 -08:00
parent ad3f3e003f
commit 5aaa45db9a
38 changed files with 4 additions and 4 deletions

52
core/commands/log.go Normal file
View File

@ -0,0 +1,52 @@
package commands
import (
"fmt"
cmds "github.com/jbenet/go-ipfs/commands"
u "github.com/jbenet/go-ipfs/util"
)
// Golang os.Args overrides * and replaces the character argument with
// an array which includes every file in the user's CWD. As a
// workaround, we use 'all' instead. The util library still uses * so
// we convert it at this step.
var logAllKeyword = "all"
var LogCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Change the logging level",
ShortDescription: `
'ipfs log' is a utility command used to change the logging
output of a running daemon.
`,
},
Arguments: []cmds.Argument{
// TODO use a different keyword for 'all' because all can theoretically
// clash with a subsystem name
cmds.StringArg("subsystem", true, false, fmt.Sprintf("the subsystem logging identifier. Use '%s' for all subsystems.", logAllKeyword)),
cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
},
Run: func(req cmds.Request) (interface{}, error) {
args := req.Arguments()
subsystem, level := args[0], args[1]
if subsystem == logAllKeyword {
subsystem = "*"
}
if err := u.SetLogLevel(subsystem, level); err != nil {
return nil, err
}
s := fmt.Sprintf("Changed log level of '%s' to '%s'", subsystem, level)
log.Info(s)
return &MessageOutput{s}, nil
},
Marshalers: cmds.MarshalerMap{
cmds.Text: MessageTextMarshaler,
},
Type: &MessageOutput{},
}