You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
874 B
33 lines
874 B
5 years ago
|
package apiv2
|
||
6 years ago
|
|
||
|
import (
|
||
|
"context"
|
||
|
"errors"
|
||
|
|
||
|
"github.com/ethereum/go-ethereum/log"
|
||
|
"github.com/harmony-one/harmony/internal/utils"
|
||
|
)
|
||
|
|
||
|
// DebugAPI Internal JSON RPC for debugging purpose
|
||
|
type DebugAPI struct {
|
||
6 years ago
|
b Backend
|
||
6 years ago
|
}
|
||
|
|
||
|
// NewDebugAPI Creates a new DebugAPI instance
|
||
6 years ago
|
func NewDebugAPI(b Backend) *DebugAPI {
|
||
6 years ago
|
return &DebugAPI{b}
|
||
|
}
|
||
|
|
||
|
// SetLogVerbosity Sets log verbosity on runtime
|
||
|
// Example usage:
|
||
|
// curl -H "Content-Type: application/json" -d '{"method":"debug_setLogVerbosity","params":[0],"id":1}' http://localhost:9123
|
||
|
func (*DebugAPI) SetLogVerbosity(ctx context.Context, level int) (map[string]interface{}, error) {
|
||
|
if level < int(log.LvlCrit) || level > int(log.LvlTrace) {
|
||
|
return nil, errors.New("invalid log level")
|
||
|
}
|
||
|
|
||
|
verbosity := log.Lvl(level)
|
||
|
utils.SetLogVerbosity(verbosity)
|
||
|
return map[string]interface{}{"verbosity": verbosity.String()}, nil
|
||
|
}
|