ArtifactLogger

This is an engine which is designed to be a drop-in logging agent for use in a Rails application.

It’s designed to be pretty simple and easy to use.

Installation:

# Gemfile
  gem "artifact_logger"

# Run this
  rake artifact_logger_engine:install:migrations

Usage:

# app/models/artifact.rb
  class Artifact < ActiveRecord::Base
    #levels are optional
    enable_artifact_logger :levels => [:info, :warning, :error, :custom]
  end

  Log::Message { 
    :level => :info, # Defaults to :info, :warning, or :error
    :text => "your message here",
    :artifact => Artifact # Either the artifact it's attached to or the artifact's class
  }

  a = Artifact.new

# To create an error or info message in the log
  m = a.log "error", "This is an error message!"
  n = a.log.info "This is an error message!"

# Both of these will display the same information
  a.log           #> [m, n]
  a.log.error     #> [m, n]

  m.artifact      #> a
  m.artifact_type #> Artifact

# This is also usable on the model itself
  info = Article.log "info", "Article did something"
  warn = Article.log.warning "Article did something else"

  Article.log         #> [warn, info]
  Article.log.warning #> [warn]

  info.artifact       #> Artifact
  info.artifact_type  #> Artifact

Future Plans:

  • Add some arbitrary linking (ie. allowing a user to be associated with a log message)

  • Add support for message types (ie. a second dimension of arbitrary scoping)

  • Explore the possiblity of tagging instead of levels and types

  • Allow for aggregate logs (ie. a parent object has access to all of it’s children’s log entries)