mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-03-28 21:10:23 +08:00
feat(kv/config): support to customize log level via env (#324)
* feat(kv/config): support to customize log level via env Author: Weny Xu <wenymedia@gmail.com> Date: Sat Nov 27 10:37:00 2021 +0900
This commit is contained in:
parent
b82206ff30
commit
8b8fdd5adf
@ -135,6 +135,7 @@ To save the hard state is also very easy, just update peer storage’s `RaftLoca
|
||||
>
|
||||
> - Use `WriteBatch` to save these states at once.
|
||||
> - See other functions at `peer_storage.go` for how to read and write these states.
|
||||
> - Set the environment variable LOG_LEVEL=debug which may help you in debugging, see also the all available [log levels](../log/log.go).
|
||||
|
||||
### Implement Raft ready process
|
||||
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/pingcap-incubator/tinykv/log"
|
||||
@ -60,11 +61,19 @@ const (
|
||||
MB uint64 = 1024 * 1024
|
||||
)
|
||||
|
||||
func getLogLevel() (logLevel string) {
|
||||
logLevel = "info"
|
||||
if l := os.Getenv("LOG_LEVEL"); len(l) != 0 {
|
||||
logLevel = l
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
SchedulerAddr: "127.0.0.1:2379",
|
||||
StoreAddr: "127.0.0.1:20160",
|
||||
LogLevel: "info",
|
||||
LogLevel: getLogLevel(),
|
||||
Raft: true,
|
||||
RaftBaseTickInterval: 1 * time.Second,
|
||||
RaftHeartbeatTicks: 2,
|
||||
@ -83,7 +92,7 @@ func NewDefaultConfig() *Config {
|
||||
|
||||
func NewTestConfig() *Config {
|
||||
return &Config{
|
||||
LogLevel: "info",
|
||||
LogLevel: getLogLevel(),
|
||||
Raft: true,
|
||||
RaftBaseTickInterval: 50 * time.Millisecond,
|
||||
RaftHeartbeatTicks: 2,
|
||||
|
Loading…
Reference in New Issue
Block a user