mispy-archive / twitter_ebooks

Better twitterbots for all your friends~
MIT License
972 stars 140 forks source link

Allow custom user formatting of log output #61

Closed stawberri closed 7 years ago

stawberri commented 9 years ago

Allows users to create an on_log method in their bots that determines what their log outputs look like.

The current log format is still the default, and this implementation reverts to it if on_log is missing or does not return a string containing log_message. If it returns anything other than that, it'll also provide a helpful warning so users know that their method is getting detected, but just not working like it should.

Example usage (with a timestamp borrowed from #55):

  def on_log(bot_name, log_message)
    # Add a timestamp to console logs this bot makes
    "#{Time.now.strftime('%c')} - #{bot_name}: #{log_message}"
  end