Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 11:16:11 +01:00
forgejo/services/f3/util/logger.go
Earl Warren e99d3f7055
feat(F3): CLI: f3 mirror to convert to/from Forgejo
feat(F3): driver stub

feat(F3): util.Logger

feat(F3): driver compliance tests

feat(F3): driver/users implementation

feat(F3): driver/user implementation

feat(F3): driver/{projects,project} implementation

feat(F3): driver/{labels,label} implementation

feat(F3): driver/{milestones,milestone} implementation

feat(F3): driver/{repositories,repository} implementation

feat(F3): driver/{organizations,organization} implementation

feat(F3): driver/{releases,release} implementation

feat(F3): driver/{issues,issue} implementation

feat(F3): driver/{comments,comment} implementation

feat(F3): driver/{assets,asset} implementation

feat(F3): driver/{pullrequests,pullrequest} implementation

feat(F3): driver/{reviews,review} implementation

feat(F3): driver/{topics,topic} implementation

feat(F3): driver/{reactions,reaction} implementation

feat(F3): driver/{reviewComments,reviewComment} implementation

feat(F3): CLI: f3 mirror

chore(F3): move to code.forgejo.org

feat(f3): upgrade to gof3 3.1.0

repositories in pull requests are represented with a reference instead
of an owner/project pair of names
2024-06-14 12:52:12 +02:00

98 lines
2.3 KiB
Go

// Copyright Earl Warren <contact@earl-warren.org>
// SPDX-License-Identifier: MIT
package util
import (
"fmt"
forgejo_log "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/migration"
"code.forgejo.org/f3/gof3/v3/logger"
)
type f3Logger struct {
m migration.Messenger
l forgejo_log.Logger
}
func (o *f3Logger) Message(message string, args ...any) {
if o.m != nil {
o.m(message, args...)
}
}
func (o *f3Logger) SetLevel(level logger.Level) {
}
func forgejoLevelToF3Level(level forgejo_log.Level) logger.Level {
switch level {
case forgejo_log.TRACE:
return logger.Trace
case forgejo_log.DEBUG:
return logger.Debug
case forgejo_log.INFO:
return logger.Info
case forgejo_log.WARN:
return logger.Warn
case forgejo_log.ERROR:
return logger.Error
case forgejo_log.FATAL:
return logger.Fatal
default:
panic(fmt.Errorf("unexpected level %d", level))
}
}
func f3LevelToForgejoLevel(level logger.Level) forgejo_log.Level {
switch level {
case logger.Trace:
return forgejo_log.TRACE
case logger.Debug:
return forgejo_log.DEBUG
case logger.Info:
return forgejo_log.INFO
case logger.Warn:
return forgejo_log.WARN
case logger.Error:
return forgejo_log.ERROR
case logger.Fatal:
return forgejo_log.FATAL
default:
panic(fmt.Errorf("unexpected level %d", level))
}
}
func (o *f3Logger) GetLevel() logger.Level {
return forgejoLevelToF3Level(o.l.GetLevel())
}
func (o *f3Logger) Log(skip int, level logger.Level, format string, args ...any) {
o.l.Log(skip+1, f3LevelToForgejoLevel(level), format, args...)
}
func (o *f3Logger) Trace(message string, args ...any) {
o.l.Log(1, forgejo_log.TRACE, message, args...)
}
func (o *f3Logger) Debug(message string, args ...any) {
o.l.Log(1, forgejo_log.DEBUG, message, args...)
}
func (o *f3Logger) Info(message string, args ...any) { o.l.Log(1, forgejo_log.INFO, message, args...) }
func (o *f3Logger) Warn(message string, args ...any) { o.l.Log(1, forgejo_log.WARN, message, args...) }
func (o *f3Logger) Error(message string, args ...any) {
o.l.Log(1, forgejo_log.ERROR, message, args...)
}
func (o *f3Logger) Fatal(message string, args ...any) {
o.l.Log(1, forgejo_log.FATAL, message, args...)
}
func NewF3Logger(messenger migration.Messenger, logger forgejo_log.Logger) logger.Interface {
return &f3Logger{
m: messenger,
l: logger,
}
}