Module: Telegram::Logging
- Included in:
- Client, ConnectionPool, TelegramBase
- Defined in:
- lib/telegram/logger.rb
Overview
Module for logging: You can use logger using this module
Class Method Summary collapse
-
.configure_logger_for(klass) ⇒ Logger
private
Create a new logger.
-
.logger_for(klass) ⇒ Logger
private
Logger pool, acquire logger from the logger table or not, create a new logger.
Instance Method Summary collapse
-
#logger ⇒ Logger
Get logger, will be initialized within a class.
Class Method Details
.configure_logger_for(klass) ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new logger
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/telegram/logger.rb', line 39 def configure_logger_for(klass) logger = Logger.new(STDOUT) logger.progname = klass logger.level = Logger::DEBUG logger.formatter = proc do |severity, datetime, progname, msg| date_format = datetime.strftime('%Y-%m-%d %H:%M:%S') blanks = severity.size == 4 ? ' ' : ' ' "[#{date_format}] #{severity}#{blanks}(#{progname}): #{msg}\n" end logger end |
.logger_for(klass) ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Logger pool, acquire logger from the logger table or not, create a new logger
30 31 32 |
# File 'lib/telegram/logger.rb', line 30 def logger_for(klass) @loggers[klass] ||= configure_logger_for(klass) end |
Instance Method Details
#logger ⇒ Logger
Get logger, will be initialized within a class
19 20 21 |
# File 'lib/telegram/logger.rb', line 19 def logger @logger ||= Logging.logger_for(self.class.name) end |