winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
899 stars 156 forks source link

Set max limit for log entry #300

Closed robertop87 closed 3 years ago

robertop87 commented 3 years ago

Hi, I'm using winston log with GAE Google Cloud Logging, where the Size of a log entry is 256KB but I have longer entries (max 1 MB).

The GAE configuration is fixed, then I cannot increase the limit. In the other hand I saw the maxsize winston configuration, but it only works for FILE size, but the log entry can be longer than the maxsize value.

So in this scenario I'm looking for a configuration or approach to limit the entry size or truncate it.

Is there a winston way to solve this?

mattberther commented 3 years ago

This is certainly not something supported by winston-daily-rotate-file. I think you may be able to implement a custom formatter (https://github.com/winstonjs/winston#formats) to do something like what you're wanting. The gist would be to have a custom formatter that takes the message and splits the string on your desired size, returning each split as an info object.

If you need further help, you might try asking over at https://github.com/winstonjs/logform (which is the library used for custom formatters).