Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with transport format functions and lack of clear documentation #431

Closed
melihcoban opened this issue Jul 25, 2024 · 1 comment
Closed

Comments

@melihcoban
Copy link

Hi,

I use electron-log 5.1.7. I inspected format page on Github docs but can't wrap my head around the implementation of it.

This example gives ts(2322) error on my end Type '({ message }: { message: any; }) => string' is not assignable to type 'Format'. Type '({ message }: { message: any; }) => string' is not assignable to type '({ message: LogMessage }: { message: any; }) => any[]'. Type 'string' is not assignable to type 'any[]'.ts(2322)

log.transports.console.format = ({ message }) => {
  return util.format(...message.data);
};

If I ignore with // @ts-ignore I get exception from electron-log itself. Unhandled electron-log error TypeError: data.reduce is not a function

Is there any explicit documentation on how to format the log message, for an example change {text} formatting?

@megahertz
Copy link
Owner

You're right, that's outdated. The function should return an array. I will update it this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants