{"id":13580868,"url":"https://github.com/discourse/logster","last_synced_at":"2025-05-13T22:02:18.905Z","repository":{"id":16479070,"uuid":"19231431","full_name":"discourse/logster","owner":"discourse","description":"Log viewer UI and framework for rack","archived":false,"fork":false,"pushed_at":"2025-03-10T22:29:35.000Z","size":9727,"stargazers_count":629,"open_issues_count":4,"forks_count":52,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-04-29T13:15:00.916Z","etag":null,"topics":["rubygem"],"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/discourse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-04-28T08:09:53.000Z","updated_at":"2025-04-20T17:37:01.000Z","dependencies_parsed_at":"2024-03-28T22:41:24.737Z","dependency_job_id":"ed56d3ff-bbe6-4a4a-a2e0-f059e18de340","html_url":"https://github.com/discourse/logster","commit_stats":{"total_commits":519,"total_committers":34,"mean_commits":"15.264705882352942","dds":0.7360308285163777,"last_synced_commit":"f3d88eb43414b5b03a63d32a838d7c2daf29a660"},"previous_names":[],"tags_count":96,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Flogster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Flogster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Flogster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Flogster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discourse","download_url":"https://codeload.github.com/discourse/logster/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036807,"owners_count":22003652,"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":["rubygem"],"created_at":"2024-08-01T15:01:55.825Z","updated_at":"2025-05-13T22:02:18.859Z","avatar_url":"https://github.com/discourse.png","language":"Ruby","readme":"![logster logo](https://raw.githubusercontent.com/discourse/logster/master/website/images/logo-logster-cropped-small.png)\n\nLogster is an embedded Ruby \"exception reporting service\" admins can view on live websites, at `http://example.com/logs`\n\n## Interface\n\n![Screenshot](https://raw.githubusercontent.com/discourse/logster/master/website/images/logster-screenshot.png)\n\nPlay with a live demo at [logster.info/logs](http://logster.info/logs).\n\n## Installation\n\nAdd these lines to your application's Gemfile:\n\n    gem 'redis'\n    gem 'logster'\n\nAnd then execute:\n\n    $ bundle\n\nTo make logster web available add the following to your `routes.rb`:\n\n```\nconstraints lambda { |req| req.session[\"admin\"] } do\n  mount Logster::Web =\u003e \"/logs\"\nend\n```\n\nBy default, logster will only run in development and production environments.\n\nTo run logster in other environments, in `config/application.rb`\n\n```\nLogster.set_environments([:development, :staging, :production])\n```\n\n### Configuration\n\nLogster can be configured using `Logster.config`:\n\n- `Logster.config.application_version`: set to a unique identifier denoting version of your app. The \"solve\" function takes this version into account when suppressing errors.\n- `Logster.config.enable_js_error_reporting` : enable js error reporting from clients\n- `Logster.config.rate_limit_error_reporting` : controls automatic 1 minute rate limiting for JS error reporting.\n- `Logster.config.web_title` : `\u003ctitle\u003e` tag for logster error page.\n\n- `Logster.config.enable_custom_patterns_via_ui` : enable the settings page (`/settings`) where you can add suppression and grouping patterns.\n\n- `Logster.config.allow_grouping` : Enable grouping of similar messages into one messages with an array of `env` of the grouped messages. Similar messages are messages that have identical backtraces, severity and log message.\n\n- `Logster.config.maximum_message_length` : set a maximum length for log messages that are shown inside the `info` tab and in the message rows in the UI. Messages that exceed the specified length will be truncated and an ellipsis will be appended to indicate that the message has been truncated. Default value is 2000.\n\n- `Logster.config.maximum_message_size_bytes` : set a maximum size for message objects. Default value is 10,000. If a message size exceeds this limit, Logster will first remove all occurrences of `gems_dir` (more on this config below) from the backtrace and computes the size again; if the message is still above the limit, Logster will remove as many as character as needed from the backtrace to bring the size below the limit. It's discouraged to set this config to a really low value (e.g. less than 2000) because a message needs a minimum amount of data in order to make sense (the minimum amount varies per message), so the closer the limit is to the minimum amount of space needed, the more of the backtrace will be removed. Keep this in mind when tweaking this config.\n\n- `Logster.config.max_env_bytes` : set a maximum size for `env`. Default value is 1000. In case `env` is an array of hashes, this limit applies to the individual hashes in the array rather than the whole array. If an `env` hash exceeds this limit, Logster will take the biggest subset of key-value pairs whose size is below the limit. If the hash has a key with the name `time`, it will always be included.\n\n- `Logster.config.max_env_count_per_message` : default value is 50. Logster can merge messages that have the same backtrace, severity and log message into one grouping message that have many `env` hashes. This config specifies the maximum number of `env` hashes a grouping message is allowed to keep. If this limit is reached and a new similar message is created and it needs to be merged, Logster will remove the oldest `env` hash from the grouping message and adds the new one.\n\n- `Logster.config.project_directories` : This should be an array of hashes that map paths on the local filesystem to GitHub repository URLs. If this feature is enabled, Logster will parse backtraces and try to construct a GitHub URL to the exact file and line number for each line in the backtrace. For a Rails app, the config may look like this: `Logster.config.project_directories = [{ path: Rails.root.to_s, url: \"https://github.com/\u003cyour_org\u003e/\u003cyour_repo\u003e\" }]`. The GitHub links that are constructed will use the `master` branch. If you want Logster to use the `application_version` attribute from the `env` tab so that the GitHub links point to the exact version of the app when the log message is created, add `main_app: true` key to the hash.\n\n- `Logster.config.enable_backtrace_links` : Enable/disable the backtrace links feature.\n\n- `Logster.config.gems_dir` : The value of this config is `Gem.dir + \"/gems/\"` by default. You probably don't need to change this config, but it's available in case your app gems are installed in a different directory. An example where this config is needed is Logster [demo site](http://logster.info/logs/): [https://github.com/discourse/logster/blob/master/website/sample.rb#L77](https://github.com/discourse/logster/blob/master/website/sample.rb#L77).\n\n- `Logster.config.back_to_site_link_path` : Path for the backlink to site.\n\n- `Logster.config.back_to_site_link_text` : Text for the backlink to site.\n\n### Tracking Error Rate\n\nLogster allows you to register a callback when the rate of errors has exceeded\na given limit.\n\nTracking buckets available are one minute and an hour.\n\nExample:\n\n```\nLogster.register_rate_limit_per_minute(Logger::WARN, 60) do |rate|\n  puts \"O no! The error rate is now #{rate} errors/min\"\nend\n\nLogster.register_rate_limit_per_hour([Logger::WARN, Logger::ERROR, Logger::FATAL], 60) do |rate|\n  puts \"O no! The error rate is now #{rate} errors/hour\"\nend\n```\n\n### Note\n\nIf you are seeing the error `No such middleware to insert before: ActionDispatch::DebugExceptions` after installing logster,\nthen you are using a conflicting gem like `better_errors` or `web-console`.\n\nTo avoid this error, make sure logster is added behind those conflicting gems in your Gemfile.\n\nIf you're using Logster with a non-rails app, you'll need to be careful that the env hashes of messages that Logster receives don't contain strings with invalid encoding because at some point Logster calls `#to_json` on the message env and the method will fail with `JSON::GeneratorError`.\n\nThe reason this doesn't happen in rails apps is because ActiveSupport has a monkey patch for [`#to_json`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/json.rb).\n\n### Mount using warden (devise)\n\n```\n  admin_constraint = lambda do |request|\n    request.env['warden'].authenticate? and request.env['warden'].user.admin?\n  end\n\n  constraints admin_constraint do\n    mount Logster::Web, at: \"/logs\"\n  end\n```\n\n### Mount using devise (method 2)\n\nChange :admin_user symbol with your devise user, example :user.\nIn -\u003e lambda block change admin? method with your authorization method\nOr simply define a admin? method in you user model.\n\n```\n  authenticate :admin_user, -\u003e(u) { u.admin? } do\n    mount Logster::Web, at: \"/logs\"\n  end\n```\n\nOut of the box, logster will use the default redis connection, to customise, in `config/application.rb`\n\n```\nLogster.store = Logster::RedisStore.new(redis_connection)\n```\n\n### Heroku Deployment\n\nIn case you may be using the `rails_12factor` gem in a production deployment on Heroku, the standard `Rails.logger` will not cooperate properly with Logster. Extend Rails.logger in your `config/application.rb` or `config/initializers/logster.rb` with:\n\n```\nif Rails.env.production?\n    Rails.logger.extend(ActiveSupport::Logger.broadcast(Logster.logger))\nend\n```\n\n## Thanks\n\nLogster UI is built using [Ember.js](http://emberjs.com/)\n\n## Contributing\n\n1. Fork it ( https://github.com/discourse/logster/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Run `cd client-app \u0026\u0026 yarn install`\n4. Run `cd website \u0026\u0026 bundle install`\n5. In the root directory, run `bundle exec rake client_dev` to start Sinatra server (port 9292) and Ember server (port 4200). Use Ember server for hot reload for client code.\n6. Visit `http://localhost:4200/logs/` (with trailing slash) to test the application. Reload `http://localhost:4200/report_error` to add sample log data.\n7. Once you're done making changes, run `./build_client_app.sh` to make and copy a production build to the assets folder.\n8. Commit your changes (`git commit -am 'Add some feature'`)\n9. Push to the branch (`git push origin my-new-feature`)\n10. Create a new Pull Request\n","funding_links":[],"categories":["Ruby","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Flogster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscourse%2Flogster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Flogster/lists"}