electron-log icon indicating copy to clipboard operation
electron-log copied to clipboard

Why does printing a long line of text result in it wrapping across multiple lines?

Open RelaxPic opened this issue 3 months ago • 5 comments

RelaxPic avatar Sep 11 '25 09:09 RelaxPic

Which transport do you mean - file, console? This library doesn't add line breaks.

megahertz avatar Sep 11 '25 09:09 megahertz

file and console. like this

13835 [2025-09-11 18:00:16.216] [error] [ 'webContents执行' ]
13836 [2025-09-11 18:00:16.216] [error] [ 'webContents执行webContents执行' ]
13837 [2025-09-11 18:00:16.216] [error] [ 'webContents执行webContents执行webContents执行' ]
13838 [2025-09-11 18:00:16.216] [error] [ 'webContents执行webContents执行webContents执行执行webContents执行' ]
13839 [2025-09-11 18:00:16.216] [error] [
13840   'webContents执行webContents执行webContents执行执行webContents执行执行webContents执行'
13841 ]
13842 [2025-09-11 18:00:16.216] [error] [
13843   'webContents执行webContents执行webContents执行执行webContents执行执行webContents执行执行webContents执行'
13844 ]

RelaxPic avatar Sep 11 '25 10:09 RelaxPic

If you pass an array type to the logger function, it formats it. You need to serialize it before passing, or use a custom format function to prevent that.

megahertz avatar Sep 11 '25 10:09 megahertz

That's not an array, it's just a relatively long string. Shouldn't parentheses wrap? ] It was wrapped up

RelaxPic avatar Sep 11 '25 10:09 RelaxPic

If you pass a string, it shouldn't print the parentheses. Maybe you use a custom formatter function, hook or transform

megahertz avatar Sep 11 '25 10:09 megahertz

I did this to avoid wrapping:

function Report(...data) {
--  scope.info(data)
++  scope.info(...data)
}


imbant avatar Dec 12 '25 09:12 imbant