@cryptotaxi247 / kubo / commits / ff987cffa

core/commands2: Added 'log' command

Matt Bell committed Nov 3, 2014 at 00:08 UTC ff987cffae0a1abce373e8269b4e5d8a63f1cf9c
2 files changed +29
core/commands2/log.go new
+28
@@ -0,0 +1,28 @@
1 +package commands
2 +
3 +import (
4 + "fmt"
5 +
6 + cmds "github.com/jbenet/go-ipfs/commands"
7 + u "github.com/jbenet/go-ipfs/util"
8 +)
9 +
10 +var logCmd = &cmds.Command{
11 + Arguments: []cmds.Argument{
12 + cmds.Argument{"subsystem", cmds.ArgString, true, false},
13 + cmds.Argument{"level", cmds.ArgString, true, false},
14 + },
15 + Help: "TODO",
16 + Run: func(res cmds.Response, req cmds.Request) {
17 + args := req.Arguments()
18 + if err := u.SetLogLevel(args[0].(string), args[1].(string)); err != nil {
19 + res.SetError(err, cmds.ErrClient)
20 + return
21 + }
22 +
23 + s := fmt.Sprintf("Changed log level of '%s' to '%s'", args[0], args[1])
24 + res.SetValue(&MessageOutput{s})
25 + },
26 + Format: MessageFormatter,
27 + Type: &MessageOutput{},
28 +}
core/commands2/root.go
+1
@@ -61,6 +61,7 @@ var rootSubcommands = map[string]*cmds.Command{
61 "commands": commandsCmd,
62 "publish": publishCmd,
63 "add": addCmd,
64 + "log": logCmd,
65
66 // test subcommands
67 // TODO: remove these when we don't need them anymore