@@ -4,7 +4,6 @@ import readline from 'node:readline'
44import colors from 'picocolors'
55import type { RollupError } from 'rollup'
66import type { ResolvedServerUrls } from './server'
7- import { splitRE } from './utils'
87
98export type LogType = 'error' | 'warn' | 'info'
109export type LogLevel = LogType | 'silent'
@@ -64,8 +63,6 @@ function getTimeFormatter() {
6463 return timeFormatter
6564}
6665
67- const MAX_LOG_CHAR = 5000
68-
6966export function createLogger (
7067 level : LogLevel = 'info' ,
7168 options : LoggerOptions = { } ,
@@ -81,32 +78,17 @@ export function createLogger(
8178 allowClearScreen && process . stdout . isTTY && ! process . env . CI
8279 const clear = canClearScreen ? clearScreen : ( ) => { }
8380
84- function preventOverflow ( msg : string ) {
85- if ( msg . length > MAX_LOG_CHAR ) {
86- const shorten = msg . slice ( 0 , MAX_LOG_CHAR )
87- const lines = msg . slice ( MAX_LOG_CHAR ) . match ( splitRE ) ?. length || 0
88-
89- return `${ shorten } \n... and ${ lines } lines more`
90- }
91- return msg
92- }
93-
94- function format (
95- type : LogType ,
96- rawMsg : string ,
97- options : LogErrorOptions = { } ,
98- ) {
99- const msg = preventOverflow ( rawMsg )
81+ function format ( type : LogType , msg : string , options : LogErrorOptions = { } ) {
10082 if ( options . timestamp ) {
101- const tag =
102- type === 'info'
103- ? colors . cyan ( colors . bold ( prefix ) )
104- : type === 'warn'
105- ? colors . yellow ( colors . bold ( prefix ) )
106- : colors . red ( colors . bold ( prefix ) )
107- return ` ${ colors . dim (
108- getTimeFormatter ( ) . format ( new Date ( ) ) ,
109- ) } ${ tag } ${ msg } `
83+ let tag = ''
84+ if ( type === 'info' ) {
85+ tag = colors . cyan ( colors . bold ( prefix ) )
86+ } else if ( type === 'warn' ) {
87+ tag = colors . yellow ( colors . bold ( prefix ) )
88+ } else {
89+ tag = colors . red ( colors . bold ( prefix ) )
90+ }
91+ return ` ${ colors . dim ( getTimeFormatter ( ) . format ( new Date ( ) ) ) } ${ tag } ${ msg } `
11092 } else {
11193 return msg
11294 }
0 commit comments