Skip to content

Commit

Permalink
revert: fix(logger): truncate log over 5000 characters long (vitejs#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry-Hong committed Jul 21, 2024
1 parent 0cde495 commit c0306c8
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions packages/vite/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import readline from 'node:readline'
import colors from 'picocolors'
import type { RollupError } from 'rollup'
import type { ResolvedServerUrls } from './server'
import { splitRE } from './utils'

export type LogType = 'error' | 'warn' | 'info'
export type LogLevel = LogType | 'silent'
Expand Down Expand Up @@ -64,8 +63,6 @@ function getTimeFormatter() {
return timeFormatter
}

const MAX_LOG_CHAR = 5000

export function createLogger(
level: LogLevel = 'info',
options: LoggerOptions = {},
Expand All @@ -81,22 +78,7 @@ export function createLogger(
allowClearScreen && process.stdout.isTTY && !process.env.CI
const clear = canClearScreen ? clearScreen : () => {}

function preventOverflow(msg: string) {
if (msg.length > MAX_LOG_CHAR) {
const shorten = msg.slice(0, MAX_LOG_CHAR)
const lines = msg.slice(MAX_LOG_CHAR).match(splitRE)?.length || 0

return `${shorten}\n... and ${lines} lines more`
}
return msg
}

function format(
type: LogType,
rawMsg: string,
options: LogErrorOptions = {},
) {
const msg = preventOverflow(rawMsg)
function format(type: LogType, msg: string, options: LogErrorOptions = {}) {
if (options.timestamp) {
const tag =
type === 'info'
Expand Down

0 comments on commit c0306c8

Please sign in to comment.