Why are we using log/slog instead of charmbracelet/log?
#1452
Closed
LarsArtmann
started this conversation in
General
Replies: 2 comments 1 reply
-
|
Note Technical Analysis: Migrating from Key Question AnsweredAfter thorough research, the answer is clear: migrate to The Short Answer
Critical Findings✅ No Compromises Needed
🎯 Perfect TUI Fit
Migration: Effort vs ImpactquadrantChart
title Migration Analysis
x-axis "Low Effort" --> "High Effort"
y-axis "Low Impact" --> "High Impact"
quadrant-1 "Quick Wins"
quadrant-2 "Major Projects"
quadrant-3 "Fill-ins"
quadrant-4 "Thankless Tasks"
"slog → charmbracelet/log": [0.6, 0.9]
Result: Classic "Quick Win" Proposed Implementation// Replace this (~40 lines):
logger := slog.NewJSONHandler(&lumberjack.Logger{...}, &slog.HandlerOptions{...})
slog.SetDefault(slog.New(logger))
// With this (~8 lines):
charmLogger := log.NewWithOptions(&lumberjack.Logger{...}, log.Options{
Formatter: log.JSONFormatter,
Level: convertLogLevel(level),
ReportTimestamp: true,
ReportCaller: true,
})
slog.SetDefault(slog.New(charmLogger))Bottom LineThis is a free upgrade:
Recommendation: Proceed immediately - it's purely beneficial with zero downside for a CLI-focused application like Crush. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I don't see any benefit to using it over slog? if you are just using LOC reduction as a metric its not a very good metric. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I asked Crush (Z.ai GLM-4.6) about our
log/slogusage and it claimed we use it in these files.Found 33 files importing
log/slog(excluding one test data file). Here are all the imports:Core files:
###Config & Log:
Agent:
CLI & TUI:
Other:
Comments / Thoughts
Apparently https://github.com/charmbracelet/log uses the
log/sloginternally too, but I don't see a real reason for not using https://github.com/charmbracelet/log to the fullest.Beta Was this translation helpful? Give feedback.
All reactions