summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-30 16:04:55 +0300
committerValery Piashchynski <[email protected]>2021-04-30 16:04:55 +0300
commit556477ca9df3fa2e5939057861314eabe5ce30ca (patch)
tree6bab1f99aa83c794060ab4c913d5ff62fef6882d
parent5f451ffbba6b9758d61ba70ddd112a8e1570045a (diff)
- Make development log colored
- Remove old TODOs Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r--pkg/events/pool_events.go1
-rwxr-xr-xpkg/pool/static_pool.go1
-rwxr-xr-xpkg/transport/pipe/pipe_factory.go4
-rw-r--r--plugins/kv/drivers/boltdb/driver.go2
-rw-r--r--plugins/logger/config.go30
-rw-r--r--plugins/reload/watcher.go3
-rw-r--r--tools/worker_table.go1
7 files changed, 26 insertions, 16 deletions
diff --git a/pkg/events/pool_events.go b/pkg/events/pool_events.go
index c569a5a8..e7b451e0 100644
--- a/pkg/events/pool_events.go
+++ b/pkg/events/pool_events.go
@@ -1,6 +1,5 @@
package events
-// TODO event numbers
const (
// EventWorkerConstruct thrown when new worker is spawned.
EventWorkerConstruct P = iota + 10000
diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go
index 129c6f7d..06005d98 100755
--- a/pkg/pool/static_pool.go
+++ b/pkg/pool/static_pool.go
@@ -153,7 +153,6 @@ func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) {
}
// worker want's to be terminated
- // TODO careful with toString(rsp.Context)
if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest {
sp.stopWorker(w)
return sp.Exec(p)
diff --git a/pkg/transport/pipe/pipe_factory.go b/pkg/transport/pipe/pipe_factory.go
index 0709413f..19f4f92d 100755
--- a/pkg/transport/pipe/pipe_factory.go
+++ b/pkg/transport/pipe/pipe_factory.go
@@ -42,7 +42,6 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
return
}
- // TODO why out is in?
in, err := cmd.StdoutPipe()
if err != nil {
c <- SpawnResult{
@@ -52,7 +51,6 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
return
}
- // TODO why in is out?
out, err := cmd.StdinPipe()
if err != nil {
c <- SpawnResult{
@@ -119,13 +117,11 @@ func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*wor
return nil, errors.E(op, err)
}
- // TODO why out is in?
in, err := cmd.StdoutPipe()
if err != nil {
return nil, errors.E(op, err)
}
- // TODO why in is out?
out, err := cmd.StdinPipe()
if err != nil {
return nil, errors.E(op, err)
diff --git a/plugins/kv/drivers/boltdb/driver.go b/plugins/kv/drivers/boltdb/driver.go
index b596d4c3..2e2df527 100644
--- a/plugins/kv/drivers/boltdb/driver.go
+++ b/plugins/kv/drivers/boltdb/driver.go
@@ -401,8 +401,6 @@ func (d *Driver) startGCLoop() { //nolint:gocognit
})
if err != nil {
d.log.Error("error during the gc phase of update", "error", err)
- // todo this error is ignored, it means, that timer still be active
- // to prevent this, we need to invoke t.Stop()
return false
}
}
diff --git a/plugins/logger/config.go b/plugins/logger/config.go
index c435e8be..d2236cac 100644
--- a/plugins/logger/config.go
+++ b/plugins/logger/config.go
@@ -40,7 +40,7 @@ type Config struct {
ErrorOutput []string `mapstructure:"errorOutput"`
}
-// ZapConfig converts config into Zap configuration.
+// BuildLogger converts config into Zap configuration.
func (cfg *Config) BuildLogger() (*zap.Logger, error) {
var zCfg zap.Config
switch strings.ToLower(cfg.Mode) {
@@ -49,7 +49,29 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
case "production":
zCfg = zap.NewProductionConfig()
case "development":
- zCfg = zap.NewDevelopmentConfig()
+ zCfg = zap.Config{
+ Level: zap.NewAtomicLevelAt(zap.DebugLevel),
+ Development: true,
+ Encoding: "console",
+ EncoderConfig: zapcore.EncoderConfig{
+ // Keys can be anything except the empty string.
+ TimeKey: "T",
+ LevelKey: "L",
+ NameKey: "N",
+ CallerKey: "C",
+ FunctionKey: zapcore.OmitKey,
+ MessageKey: "M",
+ StacktraceKey: "S",
+ LineEnding: zapcore.DefaultLineEnding,
+ EncodeLevel: ColoredLevelEncoder,
+ EncodeTime: zapcore.ISO8601TimeEncoder,
+ EncodeDuration: zapcore.StringDurationEncoder,
+ EncodeCaller: zapcore.ShortCallerEncoder,
+ EncodeName: ColoredNameEncoder,
+ },
+ OutputPaths: []string{"stderr"},
+ ErrorOutputPaths: []string{"stderr"},
+ }
case "raw":
zCfg = zap.Config{
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
@@ -98,12 +120,10 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
zCfg.ErrorOutputPaths = cfg.ErrorOutput
}
- // todo:
-
return zCfg.Build()
}
-// Initialize default logger
+// InitDefault Initialize default logger
func (cfg *Config) InitDefault() {
if cfg.Mode == "" {
cfg.Mode = "development"
diff --git a/plugins/reload/watcher.go b/plugins/reload/watcher.go
index 1b3407e5..421668b3 100644
--- a/plugins/reload/watcher.go
+++ b/plugins/reload/watcher.go
@@ -216,9 +216,8 @@ func (w *Watcher) waitEvent(d time.Duration) error {
case <-ticker.C:
// this is not very effective way
// because we have to wait on Lock
- // better is to listen files in parallel, but, since that would be used in debug... TODO
+ // better is to listen files in parallel, but, since that would be used in debug...
for serviceName := range w.watcherConfigs {
- // TODO sync approach
fileList, _ := w.retrieveFileList(serviceName, w.watcherConfigs[serviceName])
w.pollEvents(w.watcherConfigs[serviceName].ServiceName, fileList)
}
diff --git a/tools/worker_table.go b/tools/worker_table.go
index 4dd70d8e..799f045f 100644
--- a/tools/worker_table.go
+++ b/tools/worker_table.go
@@ -83,7 +83,6 @@ func renderStatus(status string) string {
}
func renderJobs(number uint64) string {
- // TODO overflow
return humanize.Comma(int64(number))
}