Files
zeekayandHanzo Dev b3323bfdf7 say what the code does now, not what it was ripped from
Four comments described a service that no longer exists, and two of them were
simply false: telemetry claimed to import "beego's logger" when it imports
visor's logs (log/slog), and tenant_context described writing to "the beego
request context" when it writes zip.Ctx locals. A comment that misdescribes the
code is worse than none — it is the version a reader trusts.

logs keeps the rationale and drops the archaeology: the signature is a format
string first because the framework logger it replaced took interface{} and
reached for Sprintf only when arguments followed, so logs.Info("failed: ", err)
lost the error into %!(EXTRA …) at runtime, in the log, where nobody was
looking. That is why the shape is a compile-time fact now. The rest of the
history is in git.

tenant_context gains the thing worth knowing: org and project OVERLAP
zip.CallerOf, which reads the same X-Org-Id/X-Project-Id off the same request.
What zip does not carry is app/tenant/actor/env, the whitelabel-hostname org
fallback and tenant-defaults-to-org — so this stays, and an op that needs only
org should ask zip rather than grow a second accessor here.

LLM.md records the state: one framework and the list that keeps it; ONE ORM
(hanzoai/xorm is indirect through hanzoai/orm, and the `xorm:` struct tags are
the tag hanzoai/orm itself reads — renaming them breaks the schema); the plane
and its asynchronous bind; and, plainly, the 72 routes still untyped and why
converting them is a two-repo change against the casibase envelope rather than
a rewrite anyone can do alone.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-05 23:38:39 -07:00

47 lines
1.9 KiB
Go

// Copyright 2023 Hanzo Industries Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package logs writes visor's leveled log lines.
//
// It is log/slog underneath, and the whole package is the signature: a format
// string and its arguments, always in that order.
//
// That signature is the point. The framework logger this replaced took an
// interface{} first argument and reached for Sprintf only when arguments
// followed, so logs.Info("failed: ", err) produced a line ending in
// %!(EXTRA *errors.errorString=…) rather than the error — a message that lost
// the one fact it was written to carry, and lost it at runtime, in the log,
// where nobody was going to be looking. Requiring a format makes that shape a
// compile-time fact instead.
package logs
import (
"fmt"
"log/slog"
)
func Info(format string, v ...any) { slog.Info(line(format, v)) }
func Warning(format string, v ...any) { slog.Warn(line(format, v)) }
func Error(format string, v ...any) { slog.Error(line(format, v)) }
// line formats only when there is something to format. Sprintf on a bare
// string turns a literal percent — a rate, a percentage in a message — into
// %!d(MISSING), so a message with no arguments is passed through as written.
func line(format string, v []any) string {
if len(v) == 0 {
return format
}
return fmt.Sprintf(format, v...)
}