Skip to content

Commit

Permalink
change in logger
Browse files Browse the repository at this point in the history
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
  • Loading branch information
MHSanaei and alireza0 committed Dec 4, 2023
1 parent 6367b1c commit 4fca34f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ func InitLogger(level logging.Level) {
var format logging.Formatter
ppid := os.Getppid()

if ppid == 1 {
backend, err = logging.NewSyslogBackend("")
format = logging.MustStringFormatter(
`%{level} - %{message}`,
)
}
if err != nil || ppid != 1 {
backend, err = logging.NewSyslogBackend("")
if err != nil {
println(err)
backend = logging.NewLogBackend(os.Stderr, "", 0)
format = logging.MustStringFormatter(
`%{time:2006/01/02 15:04:05} %{level} - %{message}`,
)
}
if ppid > 0 && err != nil {
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
} else {
format = logging.MustStringFormatter(`%{level} - %{message}`)
}

backendFormatter := logging.NewBackendFormatter(backend, format)
Expand Down

0 comments on commit 4fca34f

Please sign in to comment.