{"id":27627212,"url":"https://github.com/treasure-data/td-logger-ruby","last_synced_at":"2025-04-23T13:53:36.047Z","repository":{"id":829434,"uuid":"2242510","full_name":"treasure-data/td-logger-ruby","owner":"treasure-data","description":"Treasure Data logging library for Ruby / Rails","archived":false,"fork":false,"pushed_at":"2025-04-10T09:20:50.000Z","size":233,"stargazers_count":27,"open_issues_count":6,"forks_count":22,"subscribers_count":85,"default_branch":"master","last_synced_at":"2025-04-10T10:46:26.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://docs.treasure-data.com/articles/ruby","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treasure-data.png","metadata":{"files":{"readme":"README.rdoc","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-08-21T06:48:10.000Z","updated_at":"2025-04-10T09:20:51.000Z","dependencies_parsed_at":"2025-04-10T10:31:17.938Z","dependency_job_id":"be93854d-6582-4698-b27d-cdd3c1a4eb0a","html_url":"https://github.com/treasure-data/td-logger-ruby","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftd-logger-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftd-logger-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftd-logger-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftd-logger-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treasure-data","download_url":"https://codeload.github.com/treasure-data/td-logger-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250444217,"owners_count":21431607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T13:53:35.093Z","updated_at":"2025-04-23T13:53:36.042Z","avatar_url":"https://github.com/treasure-data.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Treasure Data logging library for Rails\n\n{\u003cimg src=\"https://travis-ci.org/treasure-data/td-logger-ruby.svg?branch=master\" alt=\"Build Status\" /\u003e}[https://travis-ci.org/treasure-data/td-logger-ruby]\n{\u003cimg src=\"https://coveralls.io/repos/treasure-data/td-logger-ruby/badge.svg?branch=master\" alt=\"Coverage Status\" /\u003e}[https://coveralls.io/r/treasure-data/td-logger-ruby?branch=master]\n\n== About\n\nThis gem is a *logging* *library* *for* *Treasure* *Data*. The events logged by this module will be uploaded into the cloud. There're two ways to upload:\n\n* *direct* *upload* *from* *applications*: app -\u003e cloud. This option is easier to configure and setup, but it requires extra memory in the application processes. The data is logged directly in the Treasure Data Cloud through the REST APIs by leveraging the {Treasure Data Ruby Client (td-client-ruby)}[https://github.com/treasure-data/td-client-ruby] library.\n* *indirect* *upload* *from* *td-agent*: app -\u003e td-agent -\u003e cloud. This option requires extra steps to install the daemons into your cluster, but lowers the logging impact on your applications. The data is sent to a td-agent running either locally or remotely by leveraging the {Fluentd Ruby Logger (fluent-logger-ruby)}[https://github.com/fluent/fluent-logger-ruby/] library.\n\nThe actual upload method can be selected in the config file as described below.\n\n== Installation\n\nAdd the following line to your Gemfile:\n\n    gem 'td-logger'\n\nFor Rails 2.x (not tested) without Bundler,\nedit +environment.rb+ and add to the initalizer block:\n\n    config.gem \"td-logger\"\n    \n== Configuration\n\n=== Direct Upload\n\nThis configuration enables the application to upload the events directly from the application processes (app -\u003e cloud) through the Treasure Data REST APIs. Please add this template +config/treasure_data.yml+ file and set your apikey:\n\n    development:\n      apikey: \"YOUR_API_KEY\"\n      database: rails_development\n      debug_mode: true  # enable debug mode\n    \n    production:\n      apikey: \"YOUR_API_KEY\"\n      database: rails_production\n      debug_mode: false\n    \n    # disable logging\n    test:\n\nIf you would wish to keep your API key as an environment variable, you can use this setting:\n\n      apikey: \u003c%= ENV['TD_API_KEY'] %\u003e\n\nAlternatively, one can initialize the Ruby Logger module for direct upload straight from within the application:\n\n    TreasureData::Logger.open('production',\n                              :apikey =\u003e \"YOUR_API_KEY\",\n                              :auto_create_table =\u003e true)\n\nThe hash key / value pairs specified in the second and following arguments of the 'open' function correspond to the configuration option of the underlying {td-client-ruby Ruby Client}[https://github.com/treasure-data/td-client-ruby#configuration] library.\n\nRefer to the {Ruby SDK documentation}[http://docs.treasuredata.com/articles/ruby-sdk] for more information.\n\nPlease note that we recommend to use a write-only API key. To obtain one, please:\n\n1. Login into the Treasure Data Console at http://console.treasuredata.com;\n2. Visit your Profile page at http://console.treasuredata.com/users/current;\n3. Insert your password under the 'API Keys' panel;\n4. In the bottom part of the panel, under 'Write-Only API keys', either copy the API key or click on 'Generate New' and copy the new API key.\n\n=== Indirect Upload\n\nWhen the 'agent' and 'tag' options are specified, the events are logged into the local td-agent daemon. Later on, the daemon uploads the event periodically to the cloud (app -\u003e td-agent -\u003e cloud).\n\nThis requires additional setup steps but lowers the memory and performance impact to your application processes. For the installation process, please look at the section {\"How to Install Treasure Agent?\"}[https://docs.treasuredata.com/articles/td-agent#how-to-install-treasure-agent] on \"Quickstart Guide\".\n\nNOTE: This configuration is not supported on PaaS platforms.\n\n    production:\n      agent: \"localhost:24224\"\n      tag: td.myapp\n      debug_mode: false\n\nAlternatively, one can initialize the Ruby Logger module for indirect upload within the application:\n\n    TreasureData::Logger.open_agent('td.myapp',\n                                    :host =\u003e 'localhost',\n                                    :port =\u003e 24224)\n\nThe arguments of the 'open_agent' function correspond to the configuration option of the underlying {Fluentd Ruby Logger (fluent-logger-ruby)}[https://github.com/fluent/fluent-logger-ruby/] library.\n\n== Logging events\n\nYou can log anytime using 'TD.event.post' method:\n\n    TD.event.post('table_name', {:foo=\u003e:bar})\n\n== Rails extension\n\nIn rails application, you can use 'TD.event.attribute' to set static attribute to all events:\n\n    class ApplicationController\n      def authenticate\n        # set 'uid' attribute to succeeding event logs\n        TD.event.attribute[:uid] = 198\n      end\n    end\n\n    class MyController \u003c ApplicationController\n      def mymethod\n        authenticate()\n        # this event includes 'uid' attribute\n        TD.event.post('table_name', {:foo=\u003e:bar})\n      end\n    end\n\n=== Test mode\n\nThis mode uses TestLogger of fluent-logger-ruby to store the events.\nIf you want to enable this mode, then specify 'test_mode' in your configuration.\n\n    development:\n      apikey: \"YOUR_API_KEY\"\n      database: rails_development\n      debug_mode: true\n      test_mode: true\n\nYou can access the logger instance via TD.logger to check the status.\n\n    TD.logger.queue #=\u003e [{},{},..]\n\n== Further Readings\n\nIf you have any problem, please refer our {document site}[https://docs.treasuredata.com/].\n\n== Copyright\n\nCopyright:: Copyright (c) 2011 Treasure Data Inc.\nLicense::   Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreasure-data%2Ftd-logger-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreasure-data%2Ftd-logger-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreasure-data%2Ftd-logger-ruby/lists"}