WideLogger
Instructure's implementation of Wide Logging in New Quizzes.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add inst-wide-logger
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install inst-wide-logger
Usage
Add variables to the logging context:
WideLogger.add_context({
user_id: current_user.id,
quiz_id: @quiz.id
})
Wrapping a code block
This will create a log entry at the end of the block with the context variables. If error is raised, the log entry will be created with the error information.
WideLogger.wrap(type: :web_request, metadata: { additional_context: @context }) do
# code to execute
end
Optionally, you can use WideLogger:DevJsonFormatter to have log entries in the following format:
<timestamp> <message> <context in JSON format>
Development
After checking out the repo, run bundle install to install dependencies. Then, run rake spec to run the tests.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/instructure-internal/wide-logger