{"id":30773043,"url":"https://github.com/zormandi/logcraft-sidekiq","last_synced_at":"2025-09-05T01:07:11.125Z","repository":{"id":45864303,"uuid":"509838132","full_name":"zormandi/logcraft-sidekiq","owner":"zormandi","description":"A structured logging solution for Sidekiq, using Logcraft.","archived":false,"fork":false,"pushed_at":"2024-07-24T07:37:01.000Z","size":63,"stargazers_count":4,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-28T01:57:03.640Z","etag":null,"topics":["logging","ruby","sidekiq"],"latest_commit_sha":null,"homepage":"","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/zormandi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-02T18:55:46.000Z","updated_at":"2025-02-27T00:24:56.000Z","dependencies_parsed_at":"2024-07-24T08:54:25.715Z","dependency_job_id":null,"html_url":"https://github.com/zormandi/logcraft-sidekiq","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"50b7129af51c28c594eab25d973b67c83155c6cc"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zormandi/logcraft-sidekiq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zormandi%2Flogcraft-sidekiq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zormandi%2Flogcraft-sidekiq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zormandi%2Flogcraft-sidekiq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zormandi%2Flogcraft-sidekiq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zormandi","download_url":"https://codeload.github.com/zormandi/logcraft-sidekiq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zormandi%2Flogcraft-sidekiq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273326077,"owners_count":25085667,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["logging","ruby","sidekiq"],"created_at":"2025-09-05T01:05:38.375Z","updated_at":"2025-09-05T01:07:11.107Z","avatar_url":"https://github.com/zormandi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logcraft::Sidekiq\n\n[![Build Status](https://github.com/zormandi/logcraft-sidekiq/actions/workflows/main.yml/badge.svg)](https://github.com/zormandi/logcraft-sidekiq/actions/workflows/main.yml)\n[![Gem Version](https://badge.fury.io/rb/logcraft-sidekiq.svg)](https://badge.fury.io/rb/logcraft-sidekiq)\n\nLogcraft::Sidekiq is a structured logging solution for [Sidekiq](https://github.com/mperham/sidekiq), using\nthe [Logcraft](https://github.com/zormandi/logcraft) gem. It supports (and is tested with) Sidekiq 6 and 7.\n\n## Installation\n\n### Rails\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'logcraft-sidekiq'\n```\n\n### Non-Rails applications\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'logcraft-sidekiq'\n```\n\nand call\n\n```ruby\nLogcraft::Sidekiq.initialize\n```\n\nany time during your application's startup.\n\n## Usage\n\n### Structured logging\n\nLogcraft::Sidekiq configures the `Sidekiq.logger` to be an instance of a Logcraft logger by the name of `Sidekiq`,\nproviding all the structured logging features that Logcraft provides, like logging complex messages, errors, etc.\nThe logger uses the same default log level that was configured for Logcraft.\n\n### Job logging\n\nLogcraft::Sidekiq logs relevant information about every job run in a compact, structured format.\n\n* It emits two log messages per job run; one when the job is started and another one when the job is finished\n  (successfully or unsuccessfully).\n* It measures the time it took to execute the job and appends the benchmark information to the final log message.\n* It adds all basic information about the job (worker, queue, JID, BID, tags, created_at, enqueued_at, run_count) to\n  the log context so all log messages emitted during the execution of the job will contain this information.\n* It also adds all of the job's parameters (by name) to the log context under the `params` key, which means that all \n  log messages emitted during the execution of the job will contain this information as well.\n\n```ruby\nclass TestWorker\n  include Sidekiq::Worker\n\n  def perform(customer_id)\n    logger.warn 'Customer not found'\n  end\nend\n\nTestWorker.perform_async 42\n\n#=\u003e {\"timestamp\":\"2022-07-17T18:23:36.320+02:00\",\"level\":\"INFO\",\"logger\":\"Sidekiq\",\"hostname\":\"MacbookPro.local\",\"pid\":20740,\"jid\":\"aad6c56ece22b115fb91821e\",\"queue\":\"default\",\"worker\":\"TestWorker\",\"created_at\":\"2022-07-17T18:23:35.932+02:00\",\"enqueued_at\":\"2022-07-17T18:23:35.932+02:00\",\"run_count\":1,\"tid\":\"hrg\",\"params\":{\"customer_id\":42},\"message\":\"TestWorker started\"}\n#=\u003e {\"timestamp\":\"2022-07-17T18:23:36.320+02:00\",\"level\":\"WARN\",\"logger\":\"Sidekiq\",\"hostname\":\"MacbookPro.local\",\"pid\":20740,\"jid\":\"aad6c56ece22b115fb91821e\",\"queue\":\"default\",\"worker\":\"TestWorker\",\"created_at\":\"2022-07-17T18:23:35.932+02:00\",\"enqueued_at\":\"2022-07-17T18:23:35.932+02:00\",\"run_count\":1,\"tid\":\"hrg\",\"params\":{\"customer_id\":42},\"message\":\"Customer not found\"}\n#=\u003e {\"timestamp\":\"2022-07-17T18:23:36.324+02:00\",\"level\":\"INFO\",\"logger\":\"Sidekiq\",\"hostname\":\"MacbookPro.local\",\"pid\":20740,\"jid\":\"aad6c56ece22b115fb91821e\",\"queue\":\"default\",\"worker\":\"TestWorker\",\"created_at\":\"2022-07-17T18:23:35.932+02:00\",\"enqueued_at\":\"2022-07-17T18:23:35.932+02:00\",\"run_count\":1,\"tid\":\"hrg\",\"params\":{\"customer_id\":42},\"duration\":4,\"duration_sec\":0.004,\"message\":\"TestWorker finished\"}\n```\n\n### Error logging\n\nLogcraft::Sidekiq sets up an error and death handler for your jobs automatically, replacing the built-in error handler.\nIf a job finishes with an error then it is logged at WARN level (assuming it will be retried) and death events are\nlogged at ERROR level. Both messages are single line events, containing all relevant information about the error.\n\n### Job-specific log level\n\nSidekiq supports setting a log level per worker but Logcraft::Sidekiq ignores this feature. Supporting it would \nlead to a lot of complexity in the code and frankly, I'm not convinced it's worth it. If you really need and\nuse this feature then please reach out to me. In the meantime, the workaround is quite simple:\n\n```ruby\n# Instead of this:\nclass TestWorker\n  include Sidekiq::Worker\n  sidekiq_options log_level: :warn\nend\n\n# Do this:\nclass TestWorker\n  include Sidekiq::Worker\n\n  def perform\n    logger = Logcraft.logger self, :warn\n    # ...\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can\nalso run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the\nversion number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,\npush git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/zormandi/logcraft-sidekiq. This project is\nintended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to\nthe [code of conduct](https://github.com/zormandi/logcraft-sidekiq/blob/master/CODE_OF_CONDUCT.md).\n\n## Disclaimer\n\nLogcraft::Sidekiq is highly opinionated software and does in no way aim or claim to be useful for everyone.\nUse at your own discretion.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Logcraft::Sidekiq project's codebases, issue trackers, chat rooms and mailing lists is\nexpected to follow the [code of conduct](https://github.com/zormandi/logcraft-sidekiq/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzormandi%2Flogcraft-sidekiq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzormandi%2Flogcraft-sidekiq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzormandi%2Flogcraft-sidekiq/lists"}