gosuki/log.go
Chakib Ben Ziane 2370500250 wip incremental sync, fixed chrome watcher
- Refactoring
- Inserting bookmarks to DBs now merges the tags
- WIP sync strategy between buffer and cache
- TODO: firefox index/buffer sync
2018-10-26 18:25:07 +02:00

41 lines
961 B
Go

package main
import (
"os"
logging "github.com/op/go-logging"
)
var (
logBackend *logging.LogBackend
log *logging.Logger
debugFormat = logging.MustStringFormatter(
`%{color}%{level:.4s} %{time:15:04:05.000} %{shortfunc:.10s}: %{color:reset} %{message}`,
)
releaseFormat = logging.MustStringFormatter(
`[%{level}] - %{message}`,
)
)
func initLogging() {
log = logging.MustGetLogger("gomark")
logBackend = logging.NewLogBackend(os.Stderr, "", 0)
if IsDebugging() {
debugBackendFormatter := logging.NewBackendFormatter(logBackend, debugFormat)
logging.SetBackend(debugBackendFormatter)
} else {
backendFormatter := logging.NewBackendFormatter(logBackend, releaseFormat)
leveledBackend := logging.AddModuleLevel(backendFormatter)
leveledBackend.SetLevel(logging.WARNING, "")
logging.SetBackend(leveledBackend)
}
log.Debugf("running in %s mode", RunMode())
}
func IsDebugging() bool {
return gomarkMode == debugCode
}