Copyright | (c) 2018-2022 Kowainik 2023-2024 Co-Log |
---|---|
License | MPL-2.0 |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
NOTE: This functionality is not to be considered stable or ready for production use. While we enourage you to try it out and report bugs, we cannot assure you that everything will work as advertised :)
Documentation
Limit for the logger rotation. Used for two purposes:
- Limit the number of kept files.
- Limit the size of the files.
:: forall r msg m. MonadIO m | |
=> Limit | Max allowed file size in bytes |
-> Limit | Max allowed number of files to have |
-> FilePath | File path to log |
-> (FilePath -> IO ()) | What to do with old files; pass |
-> (Handle -> LogAction m msg) | Action that writes to file handle |
-> (LogAction m msg -> IO r) | Continuation action |
-> IO r |
Logger rotation action. Takes name of the logging file file.foo
. Always
writes new logs to file named file.foo
(given file name, also called as hot log).
- If the size of the file exceeds given limit for file sizes then this action
renames
file.foo
tofile.foo.(n + 1)
(wheren
is the number of latest renamed file). - If the number of files on the filesystem is bigger than the files number limit
then the given
FilePath -> IO ()
action is called on the oldest file. As simple solution, you can passremoveFile
function to delete old files but you can also pass some archiving function if you don't want to lose old logs.