magillus / flutter-fimber

Fimber is Flutter logger inspired by Timber (logger API for Android)
106 stars 22 forks source link

TimedRollingFileTree is constantly rolling to new file #52

Closed sceee closed 5 years ago

sceee commented 5 years ago

I also tried the TimedRollingFileTree but unfortunately it is constantly rolling (with every log call) because in shouldRollNextFile()

    var now = DateTime.now();
    if (fileNameFormatter.format(now) !=
        fileNameFormatter.format(_currentFileDate)) {
      _currentFileDate = now;
      return true;
    }

the fileNameFormatter.format calls are always not equal and therefore true is always returned.

I am trying to initialize it the following way:

TimedRollingFileTree(
        timeSpan: TimedRollingFileTree.weeklyTime,
        filenamePrefix: '${logFilePrefix}log',
        logLevels: CustomFormatTree.defaultLevels);
magillus commented 5 years ago

Thank you for reporting it. I will check and update unit tests for this case - I thought it was catching that use case.

magillus commented 5 years ago

I found the bug - my test's logs were within 1second so the name didn't change when comparing in that method you pointed out. Working on fix

magillus commented 5 years ago

fixed in 0.3.2