MavenLogger
Easy logger for mongoid
Usage
MavenLogger requires you to have a LoggerEntry and LoggerSchema models. The simplest way is to use the generator for install maven_logger:
rails generate maven_logger:install
Next step is to determine maven_logger.rb config file which generates an event in your various classes. Set empty_log = false if you don’t want to fill in empty log info
MavenLogger.setup do |config|
config.class_actions = [
[PostsController, %i[new create]],
[Post, %i[import]],
...
]
config.empty = false
end
and add description text to maven_logger.en.yml that should be written in description of LoggerEntry Name of locale method should contain name of class with underscore. For example:
maven_logger:
posts_controller:
new: 'new post event called'
create: 'post created'
post:
import: 'the new post imported'
You can add schema statements to classes to log some info about it. For example to save the count of results:
class LoggerSchema < MavenLogger::Schema
add_schema_for Post, :import, :data_fetched
private
def self.data_fetched(result)
{ count: result.count }
end
end
Credits
Thank you, Arkadiy Butermanov for sharing your modules and other scripts from which I derived inspiration for items in this project.
Copyright © 2014 Ildus Sadykov. It is free software and may be redistributed under the terms specified in the MIT-LICENSE file.