Sha256: 277f6fcc32564e151cbe57419476ff4473d4750bba90ff5734534f1c66237c82

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

= Treasure Data logging library for Rails

== Getting Started

Add the following line to your Gemfile:

    gem 'td-logger'

For Rails 2.x (not tested) without Bundler,
edit +environment.rb+ and add to the initalizer block:

    config.gem "td-logger"

And then add +config/treasure_data.yml+ file as following:

    # logging to Treasure Data directly
    development:
      apikey: "YOUR_API_KEY"
      database: myapp
      access_log_table: access
      auto_create_table: true
    
    # logging via td-agent (fluent)
    production:
      agent: "localhost:24224"
      tag: td.myapp
      access_log_table: access
    
    # disable logging
    test:

== Logging events

You can log anytime using 'TD.event.post' method:

    class MyClass
      def mymethod
        TD.event.post('table_name', {:foo=>:bar})
      end
    end

== Rails extension

In rails application, you can use 'TD.event.attribute' to set static attribute to all events:

    class ApplicationController
      def authenticate
        # set 'uid' attribute to succeeding event logs
        TD.event.attribute[:uid] = 198
      end
    end

    class MyController < ApplicationController
      def mymethod
        authenticate()
        # this event includes 'uid' attribute
        TD.event.post('table_name', {:foo=>:bar})
      end
    end


== Copyright

Copyright:: Copyright (c) 2011 Treasure Data Inc.
License::   Apache License, Version 2.0

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
td-logger-0.3.0 README.rdoc