View Source RotatingFile (RotatingFile v0.1.0)
A GenServer that rotates a log file when it reaches a certain size. It creates a new compressed log file and deletes the oldest ones when the number of files exceeds the limit.
Summary
Functions
Returns a specification to start this module under a supervisor.
Deletes all log files.
Starts the rotating file server.
Ensures the log file is synced to disk.
Adds bytes to the log file. When no pid or name is provided, it will use the default module name.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Deletes all log files.
Starts the rotating file server.
Options
:name
- The name of the GenServer process. Defaults toRotatingFile
.:max_size
- The maximum size of the log file in bytes. Defaults to100 * 1024 * 1024
.:max_files
- The maximum number of log files to keep. Defaults to10
.:log_file
- The path to the log file. Defaults to"output.log"
.
Example
RotatingFile.start_link(name: :rotating_file, max_size: 100 * 1024 * 1024, max_files: 10, log_file: "stdout.log")
Ensures the log file is synced to disk.
Adds bytes to the log file. When no pid or name is provided, it will use the default module name.
Example
RotatingFile.write(:rotating_file, "Hello, world!
")