From 4abcd9cf0102cdcb5a7cdcbb2e54220e4c228707 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 1 Aug 2024 20:54:55 -0400 Subject: [PATCH] lang: core: Quiet down the template function by default We don't need to know this most of the time. --- lang/core/template_func.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/core/template_func.go b/lang/core/template_func.go index 71b35efd..62117d1a 100644 --- a/lang/core/template_func.go +++ b/lang/core/template_func.go @@ -241,7 +241,9 @@ func (obj *TemplateFunc) run(ctx context.Context, templateText string, vars type // XXX: should this use the scope instead (so imports are used properly) ? for name, scaffold := range simple.RegisteredFuncs { if scaffold.T == nil || scaffold.T.HasUni() { - obj.init.Logf("warning, function named: `%s` is not unified", name) + if obj.init.Debug { + obj.init.Logf("warning, function named: `%s` is not unified", name) + } continue } name = safename(name) // TODO: rename since we can't include dot @@ -257,7 +259,9 @@ func (obj *TemplateFunc) run(ctx context.Context, templateText string, vars type // type reflect.Value. f, err := wrap(ctx, name, scaffold) // wrap it so that it meets API expectations if err != nil { - obj.init.Logf("warning, skipping function named: `%s`, err: %v", name, err) + if obj.init.Debug { + obj.init.Logf("warning, skipping function named: `%s`, err: %v", name, err) + } continue } funcMap[name] = f // add it