Skip to content

Commit

Permalink
fix: update config logger (#5658)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored May 23, 2024
1 parent 439a846 commit bbbba76
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/config/src/log/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import figures from 'figures'
import { serializeObject } from './serialize.js'
import { THEME } from './theme.js'

export const logsAreBuffered = (logs) => {
return logs !== undefined && 'stdout' in logs
}

// When the `buffer` option is true, we return logs instead of printing them
// on the console. The logs are accumulated in a `logs` array variable.
export const getBufferLogs = function ({ buffer }) {
Expand All @@ -19,10 +23,14 @@ export const log = function (logs, string, { color } = {}) {
const stringA = String(string).replace(EMPTY_LINES_REGEXP, EMPTY_LINE)
const stringB = color === undefined ? stringA : color(stringA)

if (logs !== undefined) {
// `logs` is a stateful variable
if (logs && logs.outputFlusher) {
logs.outputFlusher.flush()
}

if (logsAreBuffered(logs)) {
// `logs` is a stateful variable
logs.stderr.push(stringB)

return
}

Expand Down

0 comments on commit bbbba76

Please sign in to comment.