Skip to content

Commit 0b5b8b9

Browse files
committed
refactor(logger): add progress symbol with theme.colors.step
Add dedicated `progress` symbol to LOG_SYMBOLS that uses theme.colors.step (cyan) instead of theme.colors.warning (yellow). Update progress() method to use symbols.progress for consistent theme-aware coloring. Semantic alignment: - progress: cyan ∴ (temporary progress indicators, uses step color) - reason: dimmed yellow ∴ (permanent reasoning/logic output) - step: cyan → (major step markers) This aligns with theme.colors.step being defined as "Progress indicator" and provides better visual differentiation between temporary progress updates and permanent reasoning output.
1 parent 7d17119 commit 0b5b8b9

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/logger.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { THEMES } from './themes/themes'
2525
* console.log(`${LOG_SYMBOLS.warn} Warning message`)
2626
* console.log(`${LOG_SYMBOLS.info} Information message`)
2727
* console.log(`${LOG_SYMBOLS.step} Processing step`)
28+
* console.log(`${LOG_SYMBOLS.progress} Working on task`)
2829
* console.log(`${LOG_SYMBOLS.reason} Working through logic`)
2930
* ```
3031
*/
@@ -33,6 +34,8 @@ type LogSymbols = {
3334
fail: string
3435
/** Blue colored information symbol (ℹ or i in ASCII) */
3536
info: string
37+
/** Cyan colored progress indicator symbol (∴ or :. in ASCII) */
38+
progress: string
3639
/** Dimmed yellow reasoning/working symbol (∴ or :. in ASCII) */
3740
reason: string
3841
/** Cyan colored step symbol (→ or > in ASCII) */
@@ -158,6 +161,7 @@ function applyColor(
158161
*
159162
* console.log(`${LOG_SYMBOLS.fail} Build failed`) // Theme error color ✖
160163
* console.log(`${LOG_SYMBOLS.info} Starting process`) // Theme info color ℹ
164+
* console.log(`${LOG_SYMBOLS.progress} Working on task`) // Theme step color ∴
161165
* console.log(`${LOG_SYMBOLS.reason} Analyzing dependencies`) // Dimmed yellow ∴
162166
* console.log(`${LOG_SYMBOLS.step} Processing files`) // Theme step color →
163167
* console.log(`${LOG_SYMBOLS.success} Build completed`) // Theme success color ✔
@@ -191,6 +195,7 @@ export const LOG_SYMBOLS = /*@__PURE__*/ (() => {
191195
// Update symbol values
192196
target.fail = applyColor(supported ? '✖' : '×', errorColor, colors)
193197
target.info = applyColor(supported ? 'ℹ' : 'i', infoColor, colors)
198+
target.progress = applyColor(supported ? '∴' : ':.', stepColor, colors)
194199
target.reason = colors.dim(
195200
applyColor(supported ? '∴' : ':.', warningColor, colors),
196201
)
@@ -593,6 +598,7 @@ export class Logger {
593598
__proto__: null,
594599
fail: applyColor(supported ? '✖' : '×', theme.colors.error, colors),
595600
info: applyColor(supported ? 'ℹ' : 'i', theme.colors.info, colors),
601+
progress: applyColor(supported ? '∴' : ':.', theme.colors.step, colors),
596602
reason: colors.dim(
597603
applyColor(supported ? '∴' : ':.', theme.colors.warning, colors),
598604
),
@@ -1380,7 +1386,8 @@ export class Logger {
13801386
const streamObj = (
13811387
stream === 'stderr' ? con._stderr : con._stdout
13821388
) as NodeJS.WriteStream & { write: (text: string) => boolean }
1383-
streamObj.write(`∴ ${text}`)
1389+
const symbols = this.#getSymbols()
1390+
streamObj.write(`${symbols.progress} ${text}`)
13841391
this[lastWasBlankSymbol](false)
13851392
return this
13861393
}

test/unit/logger-core.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Logger', () => {
4545
expect(LOG_SYMBOLS).toHaveProperty('fail')
4646
expect(LOG_SYMBOLS).toHaveProperty('warn')
4747
expect(LOG_SYMBOLS).toHaveProperty('info')
48+
expect(LOG_SYMBOLS).toHaveProperty('progress')
4849
expect(LOG_SYMBOLS).toHaveProperty('reason')
4950
expect(LOG_SYMBOLS).toHaveProperty('step')
5051
})
@@ -54,6 +55,7 @@ describe('Logger', () => {
5455
expect(typeof LOG_SYMBOLS.fail).toBe('string')
5556
expect(typeof LOG_SYMBOLS.warn).toBe('string')
5657
expect(typeof LOG_SYMBOLS.info).toBe('string')
58+
expect(typeof LOG_SYMBOLS.progress).toBe('string')
5759
expect(typeof LOG_SYMBOLS.reason).toBe('string')
5860
expect(typeof LOG_SYMBOLS.step).toBe('string')
5961
})
@@ -63,6 +65,7 @@ describe('Logger', () => {
6365
expect(LOG_SYMBOLS.fail.length).toBeGreaterThan(0)
6466
expect(LOG_SYMBOLS.warn.length).toBeGreaterThan(0)
6567
expect(LOG_SYMBOLS.info.length).toBeGreaterThan(0)
68+
expect(LOG_SYMBOLS.progress.length).toBeGreaterThan(0)
6669
expect(LOG_SYMBOLS.reason.length).toBeGreaterThan(0)
6770
expect(LOG_SYMBOLS.step.length).toBeGreaterThan(0)
6871
})
@@ -71,6 +74,16 @@ describe('Logger', () => {
7174
expect(Logger.LOG_SYMBOLS).toBe(LOG_SYMBOLS)
7275
expect(Logger.LOG_SYMBOLS.success).toBe(LOG_SYMBOLS.success)
7376
})
77+
78+
it('should have progress symbol containing therefore character', () => {
79+
// Progress symbol should contain ∴ (Unicode) or :. (ASCII fallback)
80+
expect(LOG_SYMBOLS.progress).toMatch(/[:]/)
81+
})
82+
83+
it('should have reason symbol containing therefore character', () => {
84+
// Reason symbol should contain ∴ (Unicode) or :. (ASCII fallback)
85+
expect(LOG_SYMBOLS.reason).toMatch(/[:]/)
86+
})
7487
})
7588

7689
describe('constructor', () => {
@@ -198,6 +211,12 @@ describe('Logger', () => {
198211
expect(result).toBe(logger)
199212
})
200213

214+
it('should support progress method', () => {
215+
const result = logger.progress('progress message')
216+
expect(result).toBe(logger)
217+
expect(stderrData.join('')).toContain('progress message')
218+
})
219+
201220
it('should support reason method', () => {
202221
const result = logger.reason('reasoning message')
203222
expect(result).toBe(logger)
@@ -208,6 +227,26 @@ describe('Logger', () => {
208227
const result = logger.step('step message')
209228
expect(result).toBe(logger)
210229
})
230+
231+
it('should include progress symbol in progress output', () => {
232+
logger.progress('test')
233+
const output = stderrData.join('')
234+
// Should contain the therefore symbol (∴ or :.)
235+
expect(output).toMatch(/[:]/)
236+
})
237+
238+
it('should write progress to stderr by default', () => {
239+
stdoutData = []
240+
stderrData = []
241+
logger.progress('testing stderr')
242+
expect(stderrData.length).toBeGreaterThan(0)
243+
expect(stderrData.join('')).toContain('testing stderr')
244+
})
245+
246+
it('should support stdout logger progress method', () => {
247+
const result = logger.stdout.progress('testing stdout')
248+
expect(result).toBe(logger.stdout)
249+
})
211250
})
212251

213252
describe('table method', () => {

0 commit comments

Comments
 (0)