Skip to content

Commit

Permalink
fix: logger
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Mar 19, 2024
1 parent 7e95f3f commit 0f38953
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func execDev(cfg *devCfg, args []string, io commands.IO) error {
loglevel = slog.LevelDebug
}

logger := clogger.NewLogger(rt, loglevel, true)
logger := clogger.NewColumnLogger(rt, loglevel, true)
loggerEvents := logger.WithGroup(EventServerLogName)
emitterServer := emitter.NewServer(loggerEvents)

Expand Down Expand Up @@ -344,7 +344,7 @@ func runPkgsWatcher(ctx context.Context, cfg *devCfg, pkgs []gnomod.Pkg, changed
}

const timeout = time.Millisecond * 500
-

var debounceTimer <-chan time.Time
pathList := []string{}

Expand Down
5 changes: 3 additions & 2 deletions contribs/gnodev/pkg/logger/log_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func NewColumnLogger(w io.Writer, level slog.Level, color bool) *slog.Logger {
colorProfile: colorProfile,
}

charmLogger.SetOutput(newColumeWriter(lipgloss.NewStyle(), "", w))
charmLogger.SetStyles(DefaultStyles())
charmLogger.SetColorProfile(colorProfile)
charmLogger.SetReportCaller(false)
Expand Down Expand Up @@ -73,7 +74,7 @@ func (cl *columnLogger) WithGroup(name string) slog.Handler {

nlog := cl.Logger.With() // clone logger
baseStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(strconv.Itoa(stringToColor(name))))
nlog.SetOutput(NewColumeWriter(baseStyle, name, cl.writer))
nlog.SetOutput(newColumeWriter(baseStyle, name, cl.writer))
nlog.SetColorProfile(cl.colorProfile)
return &columnLogger{
Logger: nlog,
Expand All @@ -91,7 +92,7 @@ type columnWriter struct {
writer io.Writer
}

func NewColumeWriter(baseStyle lipgloss.Style, prefix string, writer io.Writer) *columnWriter {
func newColumeWriter(baseStyle lipgloss.Style, prefix string, writer io.Writer) *columnWriter {
style := baseStyle.
Border(lipgloss.ThickBorder(), false, true, false, false).
BorderForeground(baseStyle.GetForeground()).
Expand Down

0 comments on commit 0f38953

Please sign in to comment.