diff --git a/logger/logger.go b/logger/logger.go index e1a8fba..66a2a19 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -27,9 +27,28 @@ func init() { // Another possibility is to add the following strings between the level and the message: // file={name},line={line},endLine={endLine},title={title} func SetGithubOutput() zerolog.Logger { - // the following formatlevel func might need to rename levels to match with github naming + // the following formatlevel loosely translates from posix levels to github levels consoleOutput.FormatLevel = func(i interface{}) string { - return fmt.Sprintf("::%s", i) + var l string + if ll, ok := i.(string); ok { + switch ll { + case zerolog.LevelTraceValue, zerolog.LevelDebugValue: + l = "debug" + case zerolog.LevelInfoValue: + l = "notice " + case zerolog.LevelWarnValue: + l = "warn " + case zerolog.LevelErrorValue, zerolog.LevelFatalValue, zerolog.LevelPanicValue: + l = "error " + default: + l = "???" + } + } else { + if i == nil { + l = "???" + } + } + return fmt.Sprintf("::%s", l) } consoleOutput.FormatMessage = func(i interface{}) string { return fmt.Sprintf("::%s", i)