{"id":21722416,"url":"https://github.com/timstott/service_logger","last_synced_at":"2025-07-06T21:07:52.397Z","repository":{"id":31737690,"uuid":"35303695","full_name":"timstott/service_logger","owner":"timstott","description":"Facilitate log aggregation via unified logging","archived":false,"fork":false,"pushed_at":"2015-05-14T11:22:23.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T19:07:09.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timstott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-08T21:58:11.000Z","updated_at":"2015-05-08T21:58:46.000Z","dependencies_parsed_at":"2022-07-20T06:32:12.723Z","dependency_job_id":null,"html_url":"https://github.com/timstott/service_logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timstott%2Fservice_logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timstott%2Fservice_logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timstott%2Fservice_logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timstott%2Fservice_logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timstott","download_url":"https://codeload.github.com/timstott/service_logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244695610,"owners_count":20494846,"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":"2024-11-26T02:28:48.874Z","updated_at":"2025-03-20T21:57:31.586Z","avatar_url":"https://github.com/timstott.png","language":"Ruby","readme":"# Loga\n\n## Description\nLoga defines a single log format, logger and middleware logger\nto faciliate log aggregation.\n\nIt provides provides:\n- Rack logger middleware\n- Sidekiq logger middleware to log jobs\n- Ruby logger\n- GELF log formatter\n- GELF log device\n\n## Road Map\n\n- [ ] CI setup with ruby 1.9 and 2.0\n- [ ] Setting to limit backtrace size\n- [ ] Setting to filter out sensitive request parameters\n- [x] Support standard Ruby logger message input\n- [ ] Hutch logging integration (Producer and Consumer)\n- [ ] ActionMailer integration (New events)\n- [ ] GELF additional fields naming retrospective\n- [ ] Hooks to augment data being logged\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'loga'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install loga\n\n## Usage\n\nConfiguration\n```ruby\n# config/initializers/loga.rb\ntarget = Loga::GELFUPDLogDevice.new(host: '192.168.99.100')\n\nLoga.configure do |config|\n  config.service_name   = 'marketplace'\n  config.service_verion = 'v1.0.0' or SHA\n  config.device         = target\nend\n```\n\nRails-less applications\n```ruby\n# config.ru\nuse Loga::Rack::Logger\n```\n\nRails applications\n```ruby\n# config/application.rb\nconfig.middleware.insert_after Rack::MethodOverride,\n                               Loga::Rack::Logger\n```\n\nSidekiq\n```ruby\n# config/initializers/sidekiq.rb\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.insert_before Sidekiq::Middleware::Server::RetryJobs,\n                        Loga::Sidekiq::ServerLogger\n  end\n  config.client_middleware do |chain|\n    chain.add Loga::Sidekiq::ClientLogger\n  end\nend\n\nSidekiq.configure_client do |config|\n  config.client_middleware do |chain|\n    chain.add Loga::Sidekiq::ClientLogger\n  end\nend\n```\n\nCustom events\n```ruby\n# Anywhere in your application\n# Passing a String\nLoga.logger.info('Hello World')\n=\u003e '{\n  \"version\":           \"1.1\",\n  \"host\":              \"example.com\",\n  \"short_message\":     \"Hello World\",\n  \"timestamp\":         \"1450171805.123\",\n  \"level\":             \"6\",\n  \"_service.name\":     \"hello_app\",\n  \"_service.version\":  \"abcdef\",\n  \"_event\":            \"unknown\"\n}'\n\n# Passing a Hash\nLoga.logger.info(\n  short_message: 'Hello World',               # REQUIRED\n  full_message:  'Hello World and the Moon',  # OPTIONAL\n  type:          'new_user',                  # OPTIONAL\n  timestamp:     Time,                        # OPTIONAL\n  data:          {                            # OPTIONAL\n    'color' =\u003e 'red',\n    'user'  =\u003e {\n      'name' =\u003e 'Bob',\n    },\n  },\n  exception:     Exception,                   # OPTIONAL\n)\n=\u003e '{\n  \"version\":           \"1.1\",\n  \"host\":              \"example.com\",\n  \"short_message\":     \"GET /hello_world\",\n  \"timestamp\":         \"1450171805.123\",\n  \"level\":             \"6\",\n  \"_service.name\":     \"hello_app\",\n  \"_service.version\":  \"abcdef\",\n  \"_event\":            \"unknown\",\n  \"_color\":            \"red\",\n  \"_user.name\":        \"Bob\"\n}'\n```\n\n## Event types\nMiddleware augment the GELF payload with the `_event` key to label events.\n\n| event type        | description                       | middleware              |\n|-------------------|-----------------------------------|-------------------------|\n| http_request      | HTTP request and response         | Rack                    |\n| job_enqueued      | Sidekiq client enqueues a job     | SidekiqClient           |\n| job_consumed      | Sidekiq worker consumes a job     | SidekiqServer           |\n| message_published | Publisher publishes a RMQ message | TODO                    |\n| message_consumed  | Consumer consumes a RMQ message   | TODO                    |\n| unknown           | Event within the application      | Logger (not middleware) |\n\n## Sample GELF\n\n:warning: Coming up\n\n## Contributing\n\n1. Fork it ( https://github.com/[my-github-username]/loga/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Credits\n- [Sidekiq](https://github.com/mperham/sidekiq)\n- [Rails](https://github.com/rails/rails)\n- [RackLogstasher](https://github.com/alphagov/rack-logstasher)\n- [gelf-rb](https://github.com/Graylog2/gelf-rb)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimstott%2Fservice_logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimstott%2Fservice_logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimstott%2Fservice_logger/lists"}