Flogs icon indicating copy to clipboard operation
Flogs copied to clipboard

Does it support automatically delete old log files?

Open bigbang489 opened this issue 4 years ago • 6 comments

I just want to keep log files for the latest 7 days, all the log beyond that time will be automatically deleted Has it been supported, and how to config it?

bigbang489 avatar Jun 09 '20 03:06 bigbang489

You can use deleteAllLogsByFilter() for this, see end of README.md please

Example: https://github.com/zubairehman/Flogs/blob/master/example/lib/main.dart#L169

slc1973 avatar Jun 09 '20 11:06 slc1973

@slc1973 I'm using the latest version 2.0, and there is no class Filter. When i try to use the deleteAllLogsByFilter from your example i get: The name 'Filter' isn't a type so it can't be used as a type argument.

I want only todays log file, how can i do that in the latest version ?

EinatK avatar Oct 19 '21 09:10 EinatK

Hello @EinatK!

I was not active ~2 years in this project :( but i already checked old version 1.2.1 of Flogs and with this old version deleteAllLogsByFilter() is working fine as expected. Example output:

I/flutter (23253): |2021-10-19 20:26:04| |LogLevel.WARNING| |HomePage| |_buildRow1| |My log| |Umair| |1634667964898|
I/flutter (23253): |2021-10-19 20:26:04| |LogLevel.ERROR| |Home| |_buildRow1| |My log| |Exception: This is a test| |Zubair| |1634667964899|
I/flutter (23253): |2021-10-19 20:26:04| |LogLevel.WARNING| |HomePage| |_buildRow1| |My log| |Umair| |1634667964899|
I/flutter (23253): Deleted 36 logs
I/flutter (23253): Deleted 12 logs
I/flutter (23253): Deleted 0 logs

Let me upgrade my development environment and project to find out was is happened last 2 years ;)

slc1973 avatar Oct 19 '21 18:10 slc1973

Hello @EinatK!

I was successful with upgrade of my development environment, see below:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.6.0-12.0.pre.390, on Ubuntu 18.04.6 LTS 5.4.0-87-generic, locale de_DE.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] Android Studio
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] VS Code (version 1.61.1)
[✓] Connected device (2 available)

• No issues found!

Upgraded Flogs to version 2.0.0-alpha-01 Started main.dart from /Flogs/example/lib folder and created some log messages with "Log Event"-button. After some time i pushed "Delete Logs by Filter (older then 10 seconds)"-button and logs older then 10 seconds are deleted. I can still confirm that deleteAllLogsByFilter() is running fine, see log below.

I/flutter (23896): {2021-10-19 21:07:05} {LogLevel.WARNING} {HomePage} {_buildRow1} {Log text/descritption goes here} {Warning (the type could be anything)} {1634670425091}
I/flutter (23896): Deleted 16 logs

How deleteAllLogsByFilter() is exactly called in example code?

          FLog.deleteAllLogsByFilter(filters: [
            Filter.lessThan(DBConstants.FIELD_TIME_IN_MILLIS,
                DateTime.now().millisecondsSinceEpoch - 1000 * 10)
          ]);

Filter.lessThan() is part from package sembast and still in version "^3.0.2" defined in pubspec.yaml...

slc1973 avatar Oct 19 '21 19:10 slc1973

@zubairehman issue can be closed

slc1973 avatar Oct 19 '21 21:10 slc1973

@slc1973 Thanks so much ! I still don't see the filter class but i added the sembast package on my own and now it works.

EinatK avatar Oct 20 '21 06:10 EinatK