megahertz/electron-log

Issues with transport format functions and lack of clear documentation

Closed this issue · 1 comments

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?

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