{"id":15876670,"url":"https://github.com/zimbatm/u-log","last_synced_at":"2026-01-20T15:33:31.961Z","repository":{"id":16934156,"uuid":"19695943","full_name":"zimbatm/u-log","owner":"zimbatm","description":"U::Log - a different take on logging","archived":false,"fork":false,"pushed_at":"2023-12-15T17:53:13.000Z","size":19,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-16T17:29:13.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.rubydoc.info/gems/u-log/","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/zimbatm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2014-05-12T11:21:23.000Z","updated_at":"2018-06-30T01:32:32.000Z","dependencies_parsed_at":"2024-10-06T02:01:20.512Z","dependency_job_id":"1ae1a520-f507-4209-8471-398f9f77f8a1","html_url":"https://github.com/zimbatm/u-log","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"cd1a98dc30021c829c3beaa99434f091341f4788"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zimbatm/u-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbatm%2Fu-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbatm%2Fu-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbatm%2Fu-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbatm%2Fu-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zimbatm","download_url":"https://codeload.github.com/zimbatm/u-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zimbatm%2Fu-log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28606142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T14:45:23.139Z","status":"ssl_error","status_checked_at":"2026-01-20T14:44:16.929Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-06T02:01:03.517Z","updated_at":"2026-01-20T15:33:31.942Z","avatar_url":"https://github.com/zimbatm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"U::Log - a different take on logging\n====================================\n\n[![Build Status](https://travis-ci.org/zimbatm/u-log.svg?branch=master)](https://travis-ci.org/zimbatm/u-log)\n\nAn oppinionated logging library.\n\n* Log everything in development AND production.\n* Logs should be easy to read, grep and parse.\n* Logging something should never fail.\n* Let the system handle the storage. Write to syslog or STDERR.\n* No log levels necessary. Just log whatever you want.\n\nSTATUS: ALPHA\n=============\n\nDoc is still scarce so it's quite hard to get started. I think reading the\nlib/u-log.rb should give a good idea of the capabilities.\n\nIt would be nice to expose a method that resolves a context into a hash. It's\nuseful to share the context with other tools like an error reporter. Btw,\nSentry/Raven is great.\n\nQuick intro\n-----------\n\n```ruby\nrequire 'u-log'\n\n# Setups the outputs. IO and Syslog are supported.\nl = U::Log.new(\n  output: $stderr,\n  format: Lines,\n  context: {\n    at:  -\u003e{ Time.now.utc },\n    pid: -\u003e{ Process.pid },\n  },\n)\n\n# First example\nl.log(foo: 'bar') # logs: at=2013-07-14T14:19:28Z foo=bar\n\n# If not a hash, the argument is transformed. A second argument is accepted as\n# a hash\nl.log(\"Hey\", count: 3) # logs: at=2013-07-14T14:19:28Z msg=Hey count=3\n\n# You can also keep a context\nclass MyClass \u003c ActiveRecord::Base\n  attr_reader :logger\n\n  def initialize(logger)\n    @logger = logger.context(my_class_id: self.id)\n  end\n\n  def do_something\n    logger.log(\"Something happened\")\n    # logs: at=2013-07-14T14:19:28Z msg='Something happeend' my_class_id: 2324\n  end\nend\n```\n\nFeatures\n--------\n\n* Simple to use\n* Thread safe (if IO#write is)\n* Designed to not raise exceptions (unless it's an IO issue)\n* A backward-compatible Logger is provided in case you want to retrofit\n* require \"u-log/active_record\" for sane ActiveRecord logs\n* \"u-log/rack_logger\" is a logging middleware for Rack\n\nKnown issues\n------------\n\nSyslog seems to truncate lines longer than 2056 chars and Lines makes if very\neasy to put too much data.\n\nLines logging speed is reasonable but it could be faster. It writes at around\n5000 lines per second to Syslog on my machine.\n\nProtocols\n---------\n\n`U::Log::Logger` is governed by a couple of protocols that help keep the\nlibrary composable.\n\nThe first constructor argument is an output. An output object is any object\nthat accepts a method call `#\u003c\u003c` with a single String argument. No output is\nexpected. The `#\u003c\u003c` method should be thread-safe is multi-threading is\nexpected.\n\nThe second contructor argument is a data formatter. It used the same protocol\nas Marshal and JSON where a `#dump` method is expected which accepts a ruby\nHash and returns a String. The formatter should not raise any exception but\ninstead transform faulty data in a readable output.\n\nConventions\n-----------\n\nWhile underscore (`_`) is commonly used to separate `CamelCase` modules to\n`camel_case.rb` file-names, no convention exists when a while library is\nprefixed by a global namespace. That's why I am taking the dash (`-`)\ncharacter for it so that `U::Log` maps to `u-log.rb`.\n\nThe `U` namespace is my prefix for very small and composable modules.\n\nInspired by\n-----------\n\n * Scrolls : https://github.com/asenchi/scrolls\n * Lograge : https://github.com/roidrage/lograge\n\nTODO\n----\n\n* Don't automatically install the logger when requiring u-log/active_record\n* Provide logging for all of rails\n* Integrate with Error reporting\n* Integrate with metrics collection\n* include U::Log to add a #log method in an object\n\nI have to think about how log lines are going to be indexed. One issue I\nencountered on the ELK stack is that JSON events can create an unknown number\nof indexec when dumped directly into ElasticSearch, because the keys in each\nevent might vary depending on which source line has produced it.\n\nWhat could be interesting is to extract only metrics. Let's say we select a\nkey format convention where all keys starting with `metrics.` are considered\nof holding a numeric value. The all the other keys are just stored alongside\nbut not indexed. If we want to add more dimensions to the metrics then more\nselect keys are added as index, selectively. Let's say \"pid\", \"hostname\" and\n\"ts\" for example.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimbatm%2Fu-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzimbatm%2Fu-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimbatm%2Fu-log/lists"}