-
Notifications
You must be signed in to change notification settings - Fork 48
/
setconfig.go
39 lines (32 loc) · 1 KB
/
setconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package main
import (
"context"
"github.com/dusk-network/dusk-protobuf/autogen/go/node"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
)
// configService implements handlers for node.ConfigService calls.
// The service is about modifying specific config settings in runtime.
// supported configs: logger.level.
//nolint
type configService struct{}
//nolint
func newConfigService(srv *grpc.Server) *configService {
cs := new(configService)
if srv != nil {
node.RegisterConfigServer(srv, cs)
}
return cs
}
func (cs *configService) ChangeLogLevel(ctx context.Context, c *node.LogLevelRequest) (*node.GenericResponse, error) {
level, err := logrus.ParseLevel(c.Level)
if err == nil {
logrus.SetLevel(level)
}
return &node.GenericResponse{}, err
}