diff --git a/cmd/forgejo/f3.go b/cmd/forgejo/f3.go index a3a7356a8a..e4ff12f8cb 100644 --- a/cmd/forgejo/f3.go +++ b/cmd/forgejo/f3.go @@ -6,14 +6,33 @@ import ( "context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/log" _ "code.gitea.io/gitea/services/f3/driver" // register the driver "github.com/urfave/cli/v2" f3_cmd "lab.forgefriends.org/friendlyforgeformat/gof3/cmd" + f3_types "lab.forgefriends.org/friendlyforgeformat/gof3/config/types" ) +func F3Logger() *f3_types.Logger { + messenger := func(message string, args ...interface{}) { + log.Info("Message: "+message, args...) + } + return &f3_types.Logger{ + Message: f3_types.LoggerFun(messenger), + Trace: log.Trace, + Debug: log.Debug, + Info: log.Info, + Warn: log.Warn, + Error: log.Error, + Critical: log.Critical, + Fatal: log.Fatal, + } +} + func CmdF3(ctx context.Context) *cli.Command { + ctx = f3_types.ContextSetLogger(ctx, F3Logger()) return &cli.Command{ Name: "f3", Usage: "F3", diff --git a/go.mod b/go.mod index 2606baa64f..7140d7f8c9 100644 --- a/go.mod +++ b/go.mod @@ -118,7 +118,7 @@ require ( gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/ini.v1 v1.67.0 gopkg.in/yaml.v3 v3.0.1 - lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230908154825-4143ad6e0e14 + lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230909181317-1e49a01bb3b7 mvdan.cc/xurls/v2 v2.5.0 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 xorm.io/builder v0.3.13 diff --git a/go.sum b/go.sum index b41ababdcd..926e37ddf7 100644 --- a/go.sum +++ b/go.sum @@ -1596,8 +1596,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230908154825-4143ad6e0e14 h1:zO8alnKMKqWXQIpygY93BwGuBpTQwcsi9dR46mp/v2U= -lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230908154825-4143ad6e0e14/go.mod h1:TcKaEsgVihjAjw290iDvvirCT0P+DZNpzc0ZgNgy3E4= +lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230909181317-1e49a01bb3b7 h1:7/4APz7dLeZ51rBxBQjwCpZBmJeOEhLIQfkuVQilN4g= +lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230909181317-1e49a01bb3b7/go.mod h1:TcKaEsgVihjAjw290iDvvirCT0P+DZNpzc0ZgNgy3E4= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= diff --git a/services/f3/driver/driver.go b/services/f3/driver/driver.go index 155e80c2eb..4495bdd821 100644 --- a/services/f3/driver/driver.go +++ b/services/f3/driver/driver.go @@ -8,8 +8,6 @@ import ( auth_model "code.gitea.io/gitea/models/auth" user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/log" - base "code.gitea.io/gitea/modules/migration" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/services/migrations" @@ -49,27 +47,8 @@ func getAuthenticationSource(ctx context.Context, authenticationSource string) ( return source, nil } -func ToF3Logger(messenger base.Messenger) *f3_types.Logger { - if messenger == nil { - messenger = func(message string, args ...interface{}) { - log.Info("Message: "+message, args...) - } - } - return &f3_types.Logger{ - Message: f3_types.LoggerFun(messenger), - Trace: log.Trace, - Debug: log.Debug, - Info: log.Info, - Warn: log.Warn, - Error: log.Error, - Critical: log.Critical, - Fatal: log.Fatal, - } -} - func (o *Options) FromFlags(ctx context.Context, c *cli.Context, prefix string) f3_types.OptionsInterface { o.Options.FromFlags(ctx, c, prefix) - o.Options.Logger = ToF3Logger(nil) sourceName := c.String("authentication-source") if sourceName != "" { source, err := getAuthenticationSource(ctx, sourceName) diff --git a/services/f3/driver/main_test.go b/services/f3/driver/main_test.go index 73291070af..bb8f8f287a 100644 --- a/services/f3/driver/main_test.go +++ b/services/f3/driver/main_test.go @@ -100,7 +100,6 @@ func (o *forgejoInstance) Init(t f3_tests.TestingT) { Type: strings.ToLower(Name), }, Features: config_types.AllFeatures, - Logger: ToF3Logger(nil), }, Doer: doer, }