Module: Chatterbot::Logging
- Included in:
- Bot
- Defined in:
- lib/chatterbot/logging.rb
Overview
routines for outputting log messages, as well as logging tweets to the database if desired.
Instance Method Summary collapse
-
#critical(s) ⇒ Object
something really bad happened, print it out and log it.
-
#debug(s) ⇒ Object
log a message.
-
#log(txt, source = nil) ⇒ Object
log a tweet to the database.
Instance Method Details
#critical(s) ⇒ Object
something really bad happened, print it out and log it
19 20 21 22 |
# File 'lib/chatterbot/logging.rb', line 19 def critical(s) puts s debug s end |
#debug(s) ⇒ Object
log a message
12 13 14 15 |
# File 'lib/chatterbot/logging.rb', line 12 def debug(s) puts s if verbose? logger.debug "#{botname} #{s}" unless ! logging? end |
#log(txt, source = nil) ⇒ Object
log a tweet to the database
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/chatterbot/logging.rb', line 26 def log(txt, source=nil) return unless log_tweets? data = {:txt => txt, :bot => botname, :created_at => Time.now} if source != nil data = data.merge(:user => source.user.screen_name, :source_id => source.id, :source_tweet => source.text) end # populate the table db[:tweets].insert(data) end |