add some todo's
This commit is contained in:
parent
69e24ec8ba
commit
717a923dff
@ -39,7 +39,7 @@ func (a *App) Run(p RunParams) {
|
||||
ctx = p.Ctx
|
||||
osArgs = p.OsArgs
|
||||
_ = p.EnvVars
|
||||
debugMode = false // TODO: replace to flag from conf
|
||||
debugMode = false // TODO: replace with flag from conf
|
||||
)
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
@ -120,6 +120,7 @@ func (c charsetUnion) RandomRune(r RandInt) rune {
|
||||
}
|
||||
|
||||
func (c charsetUnion) RandomString(r RandInt, size int) string {
|
||||
// TODO: improve distribution
|
||||
builder := strings.Builder{}
|
||||
for i := 0; i < size; i++ {
|
||||
index := r.Int() % (len(c.charsets) - 1)
|
||||
|
||||
@ -11,6 +11,7 @@ type bufioWrapper struct {
|
||||
}
|
||||
|
||||
func (b *bufioWrapper) Write(p []byte) (nn int, err error) {
|
||||
// TODO: try replace mutex, improve logging perfomance
|
||||
b.m.RLock()
|
||||
defer b.m.RUnlock()
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ type NewLoggerOpts struct {
|
||||
}
|
||||
|
||||
func New(opts NewLoggerOpts) (Logger, error) {
|
||||
// TODO: pass output streams from opts
|
||||
writers := []io.Writer{}
|
||||
writers = append(writers, os.Stderr)
|
||||
|
||||
@ -37,14 +38,19 @@ func New(opts NewLoggerOpts) (Logger, error) {
|
||||
writers = append(writers, file)
|
||||
}
|
||||
|
||||
// TODO: more log levels
|
||||
level := zerolog.TraceLevel
|
||||
if opts.Debug {
|
||||
level = zerolog.DebugLevel
|
||||
}
|
||||
|
||||
// TODO: move to wrapper, determine optimal buffer size
|
||||
writer := bufio.NewWriterSize(io.MultiWriter(writers...), 8*1024)
|
||||
wrapper := &bufioWrapper{writer, &sync.RWMutex{}}
|
||||
|
||||
// Periodically flush buffer
|
||||
go func() {
|
||||
// TODO: add cooldown if flush was triggered by overfow
|
||||
tmr := time.NewTicker(500 * time.Millisecond)
|
||||
defer tmr.Stop()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user