Logger
Ruby has a Logger class that’s accessible with require "logger". It writes log messages to a file or stream and supports automatic time- or size-based rolling of log files. Messages can be assigned severities, and only those messages at or above the logger’s current reporting level will be logged.
A new logger is created with Logger.new(location, shift_age = 0, shift_size = 1048576, **options).
The location is one of the following:
-
A string, which is interpreted as a filename; log entries are appended to the file.
-
An IO stream, in which case log entries are written to the stream. The stream can be an open File object or any of Ruby’s global streams, like $stdout, but any stream will work.
-
nil (or File::NULL), in which case log entries ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access