emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
315 stars 55 forks source link

Ability to create only date log file name #153

Closed krystejj closed 9 months ago

krystejj commented 10 months ago

Previously, it was not possible to create FileSpec for creating log file only with date in its name because if basename was set to an empty string then there was an underscore before date (_2024-01-14_00-43-30.log). Now if basename is an empty string then there is no underscore at the beginning (2024-01-14_00-43-30.log). Also added suppress_basename() function to FileSpec that just sets basename to an empty string.

Now, this:

FileSpec::default()
  .directory("logs")
  .suppress_basename();

will give you file path: logs/2024-01-14_00-43-30.log.

Previously only this was possible:

FileSpec::default()
  .directory("logs")
  .basename("");

but it was giving: logs/_2024-01-14_00-43-30.log.