github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/core/commands2/log.go (about)

     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  	Description: "Change the logging level",
    12  	Help: `'ipfs log' is a utility command used to change the logging
    13  output of a running daemon.
    14  `,
    15  
    16  	Arguments: []cmds.Argument{
    17  		cmds.StringArg("subsystem", true, false, "the subsystem logging identifier. Use * for all subsystems."),
    18  		cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
    19  	},
    20  	Run: func(req cmds.Request) (interface{}, error) {
    21  		args := req.Arguments()
    22  		if err := u.SetLogLevel(args[0].(string), args[1].(string)); err != nil {
    23  			return nil, err
    24  		}
    25  
    26  		s := fmt.Sprintf("Changed log level of '%s' to '%s'", args[0], args[1])
    27  		log.Info(s)
    28  		return &MessageOutput{s}, nil
    29  	},
    30  	Marshallers: map[cmds.EncodingType]cmds.Marshaller{
    31  		cmds.Text: MessageTextMarshaller,
    32  	},
    33  	Type: &MessageOutput{},
    34  }