Skip to content

Commit d1297fb

Browse files
committed
fix logging render
1 parent d1b9045 commit d1297fb

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

cmd/root.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"regexp"
1010
"strings"
1111

12+
"github.com/charmbracelet/lipgloss"
1213
"github.com/charmbracelet/log"
1314
"github.com/elewis787/boa"
1415
"github.com/spf13/cobra"
@@ -96,14 +97,13 @@ func setupLogger(atmosConfig *schema.AtmosConfiguration) {
9697
}
9798

9899
if atmosConfig.Settings.Terminal.NoColor {
99-
styles := log.DefaultStyles()
100+
stylesDefault := log.DefaultStyles()
100101
// Clear colors for levels
101-
styles.Levels[log.DebugLevel] = styles.Levels[log.DebugLevel].UnsetForeground()
102-
styles.Levels[log.InfoLevel] = styles.Levels[log.InfoLevel].UnsetForeground()
103-
styles.Levels[log.WarnLevel] = styles.Levels[log.WarnLevel].UnsetForeground()
104-
styles.Levels[log.ErrorLevel] = styles.Levels[log.ErrorLevel].UnsetForeground()
105-
styles.Levels[log.FatalLevel] = styles.Levels[log.FatalLevel].UnsetForeground()
106-
102+
styles := &log.Styles{}
103+
styles.Levels = make(map[log.Level]lipgloss.Style)
104+
for k, val := range stylesDefault.Levels {
105+
styles.Levels[k] = val.UnsetForeground().Bold(false)
106+
}
107107
log.SetStyles(styles)
108108
}
109109
var output io.Writer

pkg/ui/markdown/renderer.go

+23-25
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
3838

3939
if atmosConfig.Settings.Terminal.NoColor {
4040
renderer, err := glamour.NewTermRenderer(
41-
glamour.WithAutoStyle(),
41+
glamour.WithStandardStyle(styles.AsciiStyle),
4242
glamour.WithWordWrap(int(r.width)),
4343
glamour.WithColorProfile(r.profile),
4444
glamour.WithEmoji(),
@@ -75,14 +75,28 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
7575

7676
func (r *Renderer) RenderWithoutWordWrap(content string) (string, error) {
7777
// Render without line wrapping
78-
out, err := glamour.NewTermRenderer(
79-
glamour.WithAutoStyle(), // Uses terminal's default style
80-
glamour.WithWordWrap(0),
81-
glamour.WithColorProfile(r.profile),
82-
glamour.WithEmoji(),
83-
)
84-
if err != nil {
85-
return "", err
78+
var out *glamour.TermRenderer
79+
var err error
80+
if r.atmosConfig.Settings.Terminal.NoColor {
81+
out, err = glamour.NewTermRenderer(
82+
glamour.WithStandardStyle(styles.AsciiStyle),
83+
glamour.WithWordWrap(0),
84+
glamour.WithColorProfile(r.profile),
85+
glamour.WithEmoji(),
86+
)
87+
if err != nil {
88+
return "", err
89+
}
90+
} else {
91+
out, err = glamour.NewTermRenderer(
92+
glamour.WithAutoStyle(), // Uses terminal's default style
93+
glamour.WithWordWrap(0),
94+
glamour.WithColorProfile(r.profile),
95+
glamour.WithEmoji(),
96+
)
97+
if err != nil {
98+
return "", err
99+
}
86100
}
87101
result := ""
88102
if r.isTTYSupportForStdout() {
@@ -155,22 +169,6 @@ func (r *Renderer) RenderAscii(content string) (string, error) {
155169
return renderer.Render(content)
156170
}
157171

158-
// RenderWithStyle renders markdown content with a specific style
159-
func (r *Renderer) RenderWithStyle(content string, style []byte) (string, error) {
160-
renderer, err := glamour.NewTermRenderer(
161-
glamour.WithAutoStyle(),
162-
glamour.WithWordWrap(int(r.width)),
163-
glamour.WithStylesFromJSONBytes(style),
164-
glamour.WithColorProfile(r.profile),
165-
glamour.WithEmoji(),
166-
)
167-
if err != nil {
168-
return "", err
169-
}
170-
171-
return renderer.Render(content)
172-
}
173-
174172
// RenderWorkflow renders workflow documentation with specific styling
175173
func (r *Renderer) RenderWorkflow(content string) (string, error) {
176174
// Add workflow header

0 commit comments

Comments
 (0)