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

TimestampsCustomFormat with empty current_infix #161

Closed jb-alvarado closed 5 months ago

jb-alvarado commented 5 months ago

Sorry @emabee that I disturbing you again. Thank you that you have merge and optimize my pull request.

The only sad thing is now, that: when you want a empty currentinfix the logic adds a **** to the basename. For example:

let writer = FileLogWriter::builder(
    FileSpec::default()
        .suppress_timestamp()
        .basename("ffplayout")
)
.append()
.rotate(
    Criterion::Age(Age::Day),
    Naming::TimestampsCustomFormat {
        current_infix: Some(""),
        format: "%Y-%m-%d",
    },
    Cleanup::KeepLogFiles(7),
)

Gives a file: ./ffplayout_.log. My goal was to just get : ./ffplayout.log, that is the normal behavior most programs in linux logs to /var/log/.

emabee commented 5 months ago

Good point, I wasn't aware of this case. I added the support for this to 0.28.3