Class: PicklesHttpServer::Logger
- Inherits:
-
Object
- Object
- PicklesHttpServer::Logger
- Includes:
- Utils
- Defined in:
- lib/pickles_http/logger.rb
Constant Summary
Constants included from RequestMethods
RequestMethods::DELETE, RequestMethods::GET, RequestMethods::OPTIONS, RequestMethods::POST, RequestMethods::PUT
Constants included from LogMode
LogMode::DEBUG, LogMode::ERROR, LogMode::FATAL, LogMode::INFO, LogMode::SEVERITIES, LogMode::WARN
Constants included from ContentTypes
ContentTypes::HTML, ContentTypes::JSON, ContentTypes::MJS, ContentTypes::MP3
Constants included from HttpStatusCodes
HttpStatusCodes::BAD_REQUEST, HttpStatusCodes::INTERNAL_SERVER_ERROR, HttpStatusCodes::NOT_FOUND, HttpStatusCodes::OK
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(log_file, log_path: "./log.txt") ⇒ Logger
constructor
A new instance of Logger.
- #log(message, severity = LogMode::INFO) ⇒ Object
- #set_log_path(new_path) ⇒ Object
Methods included from Utils
Constructor Details
#initialize(log_file, log_path: "./log.txt") ⇒ Logger
Returns a new instance of Logger.
7 8 9 |
# File 'lib/pickles_http/logger.rb', line 7 def initialize(log_file, log_path: "./log.txt") @log_file = File.open(log_path, 'a') if log_file end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/pickles_http/logger.rb', line 21 def close @log_file.close if @log_file end |
#log(message, severity = LogMode::INFO) ⇒ Object
16 17 18 19 |
# File 'lib/pickles_http/logger.rb', line 16 def log(, severity = LogMode::INFO) severity_level = LogMode::SEVERITIES[severity.upcase] || LogMode::SEVERITIES[LogMode::INFO] log_entry(severity_level, ) end |
#set_log_path(new_path) ⇒ Object
11 12 13 14 |
# File 'lib/pickles_http/logger.rb', line 11 def set_log_path(new_path) @log_file.close if @log_file if @log_file @log_file = File.open(new_path, 'a') if @log_file end |