Class: Twitterpunch::Logger
- Inherits:
-
Object
- Object
- Twitterpunch::Logger
- Defined in:
- lib/twitterpunch/logger.rb
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(config) ⇒ Logger
constructor
A new instance of Logger.
- #log(username, message) ⇒ Object
Constructor Details
#initialize(config) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 12 13 |
# File 'lib/twitterpunch/logger.rb', line 8 def initialize(config) @options = config @logger = ::Logger.new(File.(config[:logfile])) @logger.level = config[:debug] ? ::Logger::DEBUG : ::Logger::INFO end |
Instance Method Details
#debug(message) ⇒ Object
20 21 22 23 24 |
# File 'lib/twitterpunch/logger.rb', line 20 def debug() return unless @options[:debug] puts .yellow @logger.debug() end |
#error(message) ⇒ Object
15 16 17 18 |
# File 'lib/twitterpunch/logger.rb', line 15 def error() puts .red @logger.error() end |
#info(message) ⇒ Object
26 27 28 |
# File 'lib/twitterpunch/logger.rb', line 26 def info() puts .green unless @options[:quiet] end |
#log(username, message) ⇒ Object
30 31 32 |
# File 'lib/twitterpunch/logger.rb', line 30 def log(username, ) @logger.info(sprintf("%15s: %s", username, )) end |