diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-06-16 08:17:42 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-06-18 13:03:04 +0200 |
commit | 7c9fada778e91976d4ba1cbe942235a9bbeaf5cb (patch) | |
tree | a717f6e0a5915777ae6859564acd13385213bbab /langs | |
parent | 0e7944658660b5658b7640dce3cb346d7198d8c9 (diff) | |
download | hugo-7c9fada778e91976d4ba1cbe942235a9bbeaf5cb.tar.gz hugo-7c9fada778e91976d4ba1cbe942235a9bbeaf5cb.zip |
Replace the old log setup, with structured logging etc.
Fixes #11124
Diffstat (limited to 'langs')
-rw-r--r-- | langs/i18n/i18n.go | 5 | ||||
-rw-r--r-- | langs/i18n/i18n_test.go | 7 |
2 files changed, 5 insertions, 7 deletions
diff --git a/langs/i18n/i18n.go b/langs/i18n/i18n.go index a9b7b4c97..1ebd039cd 100644 --- a/langs/i18n/i18n.go +++ b/langs/i18n/i18n.go @@ -24,7 +24,6 @@ import ( "github.com/gohugoio/hugo/common/hreflect" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" - "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/go-i18n/v2/i18n" @@ -32,8 +31,6 @@ import ( type translateFunc func(ctx context.Context, translationID string, templateData any) string -var i18nWarningLogger = helpers.NewDistinctErrorLogger() - // Translator handles i18n translations. type Translator struct { translateFuncs map[string]translateFunc @@ -123,7 +120,7 @@ func (t Translator) initFuncs(bndl *i18n.Bundle) { } if t.cfg.LogI18nWarnings() { - i18nWarningLogger.Printf("i18n|MISSING_TRANSLATION|%s|%s", currentLangStr, translationID) + t.logger.Warnf("i18n|MISSING_TRANSLATION|%s|%s", currentLangStr, translationID) } if enableMissingTranslationPlaceholders { diff --git a/langs/i18n/i18n_test.go b/langs/i18n/i18n_test.go index 1ac6144dd..8629c35fc 100644 --- a/langs/i18n/i18n_test.go +++ b/langs/i18n/i18n_test.go @@ -19,12 +19,13 @@ import ( "path/filepath" "testing" + "github.com/bep/logg" + "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/config/testconfig" "github.com/gohugoio/hugo/tpl/tplimpl" - "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/resources/page" "github.com/spf13/afero" @@ -34,7 +35,7 @@ import ( "github.com/gohugoio/hugo/config" ) -var logger = loggers.NewErrorLogger() +var logger = loggers.NewDefault() type i18nTest struct { name string @@ -406,7 +407,7 @@ other = "{{ . }} miesiąca" for _, variant := range test.variants { c.Assert(f(ctx, test.id, variant.Key), qt.Equals, variant.Value, qt.Commentf("input: %v", variant.Key)) - c.Assert(int(d.Log.LogCounters().WarnCounter.Count()), qt.Equals, 0) + c.Assert(d.Log.LoggCount(logg.LevelWarn), qt.Equals, 0) } }) |