mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
core/commands2: Added 'log' command
This commit is contained in:

committed by
Juan Batiz-Benet

parent
3c4e7bf9a1
commit
ff987cffae
28
core/commands2/log.go
Normal file
28
core/commands2/log.go
Normal file
@ -0,0 +1,28 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
cmds "github.com/jbenet/go-ipfs/commands"
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var logCmd = &cmds.Command{
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"subsystem", cmds.ArgString, true, false},
|
||||
cmds.Argument{"level", cmds.ArgString, true, false},
|
||||
},
|
||||
Help: "TODO",
|
||||
Run: func(res cmds.Response, req cmds.Request) {
|
||||
args := req.Arguments()
|
||||
if err := u.SetLogLevel(args[0].(string), args[1].(string)); err != nil {
|
||||
res.SetError(err, cmds.ErrClient)
|
||||
return
|
||||
}
|
||||
|
||||
s := fmt.Sprintf("Changed log level of '%s' to '%s'", args[0], args[1])
|
||||
res.SetValue(&MessageOutput{s})
|
||||
},
|
||||
Format: MessageFormatter,
|
||||
Type: &MessageOutput{},
|
||||
}
|
@ -61,6 +61,7 @@ var rootSubcommands = map[string]*cmds.Command{
|
||||
"commands": commandsCmd,
|
||||
"publish": publishCmd,
|
||||
"add": addCmd,
|
||||
"log": logCmd,
|
||||
|
||||
// test subcommands
|
||||
// TODO: remove these when we don't need them anymore
|
||||
|
Reference in New Issue
Block a user