{"id":28466536,"url":"https://github.com/the-vk/intake","last_synced_at":"2025-10-03T23:02:18.083Z","repository":{"id":60663439,"uuid":"540236507","full_name":"the-vk/intake","owner":"the-vk","description":"Powerful and extensible logging libraryYet another Ruby logging library","archived":false,"fork":false,"pushed_at":"2022-10-30T20:18:57.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-01T20:16:39.620Z","etag":null,"topics":["logger","logging","ruby"],"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/the-vk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-23T01:39:30.000Z","updated_at":"2022-10-09T23:33:17.000Z","dependencies_parsed_at":"2022-10-02T21:30:20.918Z","dependency_job_id":null,"html_url":"https://github.com/the-vk/intake","commit_stats":null,"previous_names":["the-vk/log_sinks"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/the-vk/intake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-vk%2Fintake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-vk%2Fintake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-vk%2Fintake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-vk%2Fintake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-vk","download_url":"https://codeload.github.com/the-vk/intake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-vk%2Fintake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278239978,"owners_count":25954098,"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-10-03T02:00:06.070Z","response_time":53,"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":["logger","logging","ruby"],"created_at":"2025-06-07T07:04:43.957Z","updated_at":"2025-10-03T23:02:18.019Z","avatar_url":"https://github.com/the-vk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![.github/workflows/rsspec.yml](https://github.com/the-vk/intake/actions/workflows/rspec.yml/badge.svg)](https://github.com/the-vk/intake/actions/workflows/rspec.yml)\n\n# intake\n\n## Description\n\n**intake** is a powerful and easy to use logging library.\nThe library is designed with multiple base principles:\n\n* Be a drop-in replacement for Ruby `Logger`\n* Advanced API to support structured logging\n* Highly efficient non-blocking logger API\n\n## Installation\n\n```shell\ngem install intake\n```\n\n## Design\n\n**intake** has two primary components:\n\n* Logger\n* Sink\n\n**Intake::Logger** is a component that captures a logging event and forwards that to **Intake::EventDrain** which is a single point to collect log events.\n\nA logger may optionally filter events by filter to quickly discard events with level below threshold.\n\n**Intake::Sink** is a component that receives event logs and writes to a permanent storage.\n\nA sink may filter events by level, logger name, or any other event attributes.\n\n## Examples\n\nThis example sets up logging to write messages to STDOUT.\n**intake** writes messages in Ruby Logger format.\n```ruby\nrequire 'intake`\n\nlog = Intake[:root]\nlog.level = :info\nIntake.add_sink Intake::IOSink.new($stdout)\n\nlog.debug 'debug message'\nlog.debug { 'proc debug message' }\n# Logger methods can take a block to generate log message\n# Blocks allow to delay expensive message evaluation until and unless event is logged\nlog.debug do\n  print(\"you don't see me!\")\n  'expensive proc debug message'\nend\nlog.info 'info message'\nlog.info { 'proc info message' }\nlog.warn 'warn message'\nlog.warn { 'proc warn message' }\nlog.error 'error message'\nlog.error { 'proc error message' }\nlog.fatal 'fatal message'\nlog.fatal { 'proc fatal message' }\n```\n\nOutput:\n\n```\nI, [2022-10-09T15:57:58.377963 #12484] INFO -- : info message\nI, [2022-10-09T15:57:58.378097 #12484] INFO -- : proc info message\nW, [2022-10-09T15:57:58.378121 #12484] WARN -- : warn message\nW, [2022-10-09T15:57:58.378133 #12484] WARN -- : proc warn message\nE, [2022-10-09T15:57:58.378169 #12484] ERROR -- : error message\nE, [2022-10-09T15:57:58.378212 #12484] ERROR -- : proc error message\nF, [2022-10-09T15:57:58.378255 #12484] FATAL -- : fatal message\nF, [2022-10-09T15:57:58.378297 #12484] FATAL -- : proc fatal message\n```\n\n### Sinks and filters\n\n**intake** supports multuple target sinks with various filters.\n\n```ruby\nlog = Intake[:root]\nlog.level = :debug\nio_sink = Intake::IOSink.new($stdout)\n# filter is a proc-like object to make a decision on events\n# event is accepted by sink if #call(event) returns true\nio_sink.add_filter Intake::Filters::LevelFilter.new(:warn)\nIntake.add_sink io_sink\nfile_sink = Intake::IOSink.new(File.new('/dev/null', 'a'))\nfile_sink.add_filter Intake::Filters::LevelFilter.new(:info)\n\nlog.debug 'debug message'     # not logged\nlog.info 'info message'       # logged to file\nlog.warn 'warn message'       # logged to both stdout and file\nlog.error 'error message'     # logged to both stdout and file\nlog.fatal 'fatal message'     # logged to both stdout and file\n```\n\nOutput:\n\n```\nW, [2022-10-09T16:08:48.752905 #14476] WARN -- : warn message\nE, [2022-10-09T16:08:48.752983 #14476] ERROR -- : error message\nF, [2022-10-09T16:08:48.753031 #14476] FATAL -- : fatal message\n```\n\n### MDC\n\nMapped diagnostic context (MDC) is a thread-local storage to attach extra information to log events, e.g. operation id or correlation id.\n\n```ruby\nlog = Intake[:root]\nlog.level = :info\nsink = Intake::IOSink.new($stdout)\nsink.formatter = -\u003e(e) { \"#{e.timestamp} [#{e[:correlation_id]}] - #{e.logger_name}: - #{e.message}\\n\" }\nIntake.add_sink sink\n\nlog.info 'a message'\n\nIntake::MDC[:correlation_id] = :abc\n\nlog.info 'message with MDC'\n\nIntake::MDC.clear(:correlation_id)\n\nlog.info 'a message with no MDC'\n```\n\nOutput:\n\n```\n2022-10-09 16:13:23 -0700 [] - root: - a message\n2022-10-09 16:13:23 -0700 [abc] - root: - message with MDC\n2022-10-09 16:13:23 -0700 [] - root: - a message with no MDC\n```\n\n### Structured logging\n\n**Intake::Logger** methods takes optional keyword argument **meta** with a Hash with extra details about log event.\nSink may write meta to output in structured format that allows to query logs.\n\n```ruby\nlog = Intake[:root]\nlog.level = :info\nsink = Intake::IOSink.new($stdout)\nsink.formatter = -\u003e(e) { \"#{e.timestamp} [#{e[:user_id]}] - #{e.logger_name}: - #{e.message}\\n\" }\nIntake.add_sink sink\n\nlog.info 'a message', meta: { user_id: 'username' }\n```\n\nOutput:\n\n```\n2022-10-09 16:18:21 -0700 [username] - root: - a message\n```\n### Ruby Logger adapter\n\n**intake** provides an adapter to Ruby Logger API. Adapter can be used as drop-in replacement of regular Ruby Logger.\n\n```ruby\nrequire 'intake'\n\nlog = Intake[:root]\nIntake.add_sink Intake::IOSink.new($stdout)\nlog.level = :debug\nlog = log.as_ruby_logger\n\nlog.add(Logger::Severity::FATAL, 'msg', 'sample')\n\nlog.debug 'debug'\nlog.info 'info'\nlog.warn 'warn'\nlog.error 'error'\nlog.fatal 'fatal'\nlog.unknown 'unknown'\n\nlog.warn { 'warn proc message' }\n\nlog = Intake[:root].as_ruby_logger(progname: 'sample')\n\nlog.debug 'debug'\nlog.info 'info'\nlog.warn 'warn'\nlog.error 'error'\nlog.fatal 'fatal'\nlog.unknown 'unknown'\n\nlog.warn { 'warn proc message' }\n```\n\nOutput:\n\n```\nF, [2022-10-09T16:16:13.918872 #14918] FATAL -- sample: msg\nD, [2022-10-09T16:16:13.918992 #14918] DEBUG -- : debug\nI, [2022-10-09T16:16:13.919053 #14918] INFO -- : info\nW, [2022-10-09T16:16:13.919114 #14918] WARN -- : warn\nE, [2022-10-09T16:16:13.919143 #14918] ERROR -- : error\nF, [2022-10-09T16:16:13.919191 #14918] FATAL -- : fatal\nF, [2022-10-09T16:16:13.919219 #14918] FATAL -- : unknown\nW, [2022-10-09T16:16:13.919267 #14918] WARN -- : warn proc message\nD, [2022-10-09T16:16:13.919319 #14918] DEBUG -- sample: debug\nI, [2022-10-09T16:16:13.919363 #14918] INFO -- sample: info\nW, [2022-10-09T16:16:13.919417 #14918] WARN -- sample: warn\nE, [2022-10-09T16:16:13.919442 #14918] ERROR -- sample: error\nF, [2022-10-09T16:16:13.919491 #14918] FATAL -- sample: fatal\nF, [2022-10-09T16:16:13.919542 #14918] FATAL -- sample: unknown\nW, [2022-10-09T16:16:13.919594 #14918] WARN -- sample: warn proc message\n```\n\n## License\n\nThe MIT License. See the [LICENSE](/LICENSE) file for the full text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-vk%2Fintake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-vk%2Fintake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-vk%2Fintake/lists"}