Code Monkey home page Code Monkey logo

logster's Introduction

logster logo

Logster is an embedded Ruby "exception reporting service" admins can view on live websites, at http://example.com/logs

Interface

Screenshot

Play with a live demo at logster.info/logs.

Installation

Add these lines to your application's Gemfile:

gem 'redis'
gem 'logster'

And then execute:

$ bundle

To make logster web available add the following to your routes.rb:

constraints lambda { |req| req.session["admin"] } do
  mount Logster::Web => "/logs"
end

By default, logster will only run in development and production environments.

To run logster in other environments, in config/application.rb

Logster.set_environments([:development, :staging, :production])

Configuration

Logster can be configured using Logster.config:

  • 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.

  • Logster.config.enable_js_error_reporting : enable js error reporting from clients

  • Logster.config.rate_limit_error_reporting : controls automatic 1 minute rate limiting for JS error reporting.

  • Logster.config.web_title : <title> tag for logster error page.

  • Logster.config.enable_custom_patterns_via_ui : enable the settings page (/settings) where you can add suppression and grouping patterns.

  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

  • 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/<your_org>/<your_repo>" }]. 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.

  • Logster.config.enable_backtrace_links : Enable/disable the backtrace links feature.

  • 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: https://github.com/discourse/logster/blob/master/website/sample.rb#L77.

  • Logster.config.back_to_site_link_path : Path for the backlink to site.

  • Logster.config.back_to_site_link_text : Text for the backlink to site.

Tracking Error Rate

Logster allows you to register a callback when the rate of errors has exceeded a given limit.

Tracking buckets available are one minute and an hour.

Example:

Logster.register_rate_limit_per_minute(Logger::WARN, 60) do |rate|
  puts "O no! The error rate is now #{rate} errors/min"
end

Logster.register_rate_limit_per_hour([Logger::WARN, Logger::ERROR, Logger::FATAL], 60) do |rate|
  puts "O no! The error rate is now #{rate} errors/hour"
end

Note

If you are seeing the error No such middleware to insert before: ActionDispatch::DebugExceptions after installing logster, then you are using a conflicting gem like better_errors or web-console.

To avoid this error, make sure logster is added behind those conflicting gems in your Gemfile.

If 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.

The reason this doesn't happen in rails apps is because ActiveSupport has a monkey patch for #to_json.

Mount using warden (devise)

  admin_constraint = lambda do |request|
    request.env['warden'].authenticate? and request.env['warden'].user.admin?
  end

  constraints admin_constraint do
    mount Logster::Web, at: "/logs"
  end

Mount using devise (method 2)

Change :admin_user symbol with your devise user, example :user. In -> lambda block change admin? method with your authorization method Or simply define a admin? method in you user model.

  authenticate :admin_user, ->(u) { u.admin? } do
    mount Logster::Web, at: "/logs"
  end

Out of the box, logster will use the default redis connection, to customise, in config/application.rb

Logster.store = Logster::RedisStore.new(redis_connection)

Heroku Deployment

In 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:

if Rails.env.production?
    Rails.logger.extend(ActiveSupport::Logger.broadcast(Logster.logger))
end

Thanks

Logster UI is built using Ember.js

Contributing

  1. Fork it ( https://github.com/discourse/logster/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Run cd client-app && yarn install
  4. Run cd website && bundle install
  5. 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.
  6. Visit http://localhost:4200/logs/ (with trailing slash) to test the application. Reload http://localhost:4200/report_error to add sample log data.
  7. Once you're done making changes, run ./build_client_app.sh to make and copy a production build to the assets folder.
  8. Commit your changes (git commit -am 'Add some feature')
  9. Push to the branch (git push origin my-new-feature)
  10. Create a new Pull Request

logster's People

Contributors

aaronlasseigne avatar bbonamin avatar benubois avatar bf4 avatar bitsapien avatar coding-horror avatar cvx avatar davidtaylorhq avatar dependabot[bot] avatar eviltrout avatar flink avatar gschlager avatar hlcfan avatar janzenisaac avatar jiajiawang avatar koss-lebedev avatar lis2 avatar lumenlunae avatar majakomel avatar nattsw avatar nbianca avatar nlalonde avatar osamasayegh avatar riking avatar samsaffron avatar supermathie avatar tgxworld avatar wpp avatar xrav3nz avatar zogstrip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logster's Issues

Bug with X-Accel-Redirect

When X-Accel-Redirect is set and configured, logster stop working : Rack doesn't find files to send (assets).

!

fixed.

`No such middleware to insert before: ActionDispatch::DebugExceptions`

I just added to my Gemfile:

gem 'logster'
gem 'redis' # this was already installed because of sidekiq

but when I try to start the app, it throws:

=> Booting Puma
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/stack.rb:125:in `assert_index': No such middleware to insert before: ActionDispatch::DebugExceptions (RuntimeError)
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/stack.rb:88:in `insert'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/configuration.rb:68:in `block in merge_into'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/configuration.rb:67:in `each'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/configuration.rb:67:in `merge_into'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/engine.rb:501:in `app'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/application/finisher.rb:34:in `block in <module:Finisher>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `run'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `each'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `call'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/application.rb:352:in `initialize!'
        from /files/alter/workspace/productswatcher/config/environment.rb:5:in `<top (required)>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
        from /files/alter/workspace/productswatcher/config.ru:3:in `block in <main>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/builder.rb:55:in `instance_eval'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/builder.rb:55:in `initialize'
        from /files/alter/workspace/productswatcher/config.ru:in `new'
        from /files/alter/workspace/productswatcher/config.ru:in `<main>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/builder.rb:49:in `eval'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/builder.rb:49:in `new_from_string'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/builder.rb:40:in `parse_file'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/server.rb:300:in `build_app_and_options_from_config'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/server.rb:209:in `app'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/server.rb:61:in `app'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/rack-1.6.8/lib/rack/server.rb:337:in `wrapped_app'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/server.rb:139:in `log_to_stdout'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/server.rb:78:in `start'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:80:in `block in server'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:75:in `server'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<top (required)>'
        from /files/alter/workspace/productswatcher/bin/rails:8:in `require'
        from /files/alter/workspace/productswatcher/bin/rails:8:in `<top (required)>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `load'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in `call'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/client/command.rb:7:in `call'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/client.rb:30:in `run'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/bin/spring:49:in `<top (required)>'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `load'
        from /home/alter/.rvm/gems/ruby-2.2.5@productwatcher/gems/spring-1.7.1/lib/spring/binstub.rb:11:in `<top (required)>'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /files/alter/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /files/alter/workspace/productswatcher/bin/spring:13:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

and it happens adding or not the mount to my routes.rb file.
What I'm missing here?

Multiple NoMethodErrors in Rails 5 with quiet assets

Greetings! First of all, thank you for this awesome, quick-and-dirty log viewer. I was about to write one myself when I found it. I've already found it to be very useful.

Unfortunately, in the course of updating an app to Rails 5 I've run into an issue. When config.assets.quiet = true is set, I am seeing multiple NoMethodErrors causing my assets to fail in development.

I have created an example app at https://github.com/alassek/logster-example.

I was able to work around the first error with Logster::Logger.include LoggerSilence, but that leads to a different error involving local_level=.

Doesn't work in production

Hi! Logster works in development but not on my production server.

The page is well displayed, Ajax call are made to refresh the view, but nothing appears...

Any idea?

Heroku deployment

Hi!

How do you specify Redis params for an Heroku style deployment? (Redis is living in a container and the Rails app in an other one)

Thank you!

undefined method `broadcast_to'

Hello,

I have logster and redis installed in my Rails 7.1.1 app. When I start up my rails server I get the following errors;

20:21:31 sidekiq.1 | undefined method `broadcast_to' for #<Logster::DeferLogger:0x0000000114553498 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00000001145ffe28 @datetime_format=nil>, @formatter=nil, @logdev=nil, @store=#<Logster::RedisStore:0x0000000114553ad8 @max_retention=604800, @skip_empty=true, @allow_custom_patterns=false, @patterns_cache=#<Logster::Cache:0x00000001145d20b8 @age=2, @hash={}>, @redis=#<Redis client v5.0.7 for redis://localhost:6379/0>, @max_backlog=1000, @redis_prefix=nil, @redis_raw_connection=nil>, @chained=[#<ActiveSupport::BroadcastLogger:0x000000011453b500 @broadcasts=[#<ActiveSupport::Logger:0x00000001144b9438 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00000001144d6150 @datetime_format=nil>, @formatter=#<Logger::Formatter:0x00000001144d3928 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x00000001144b9ed8 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @binmode=false, @mon_data=#<Monitor:0x00000001144d5f70>, @mon_data_owner_object_id=5120>, @local_level_key=:logger_thread_safe_level_9060>], @progname="Broadcast", @formatter=#<Logger::Formatter:0x00000001144d3928 @datetime_format=nil>>], @skip_store=false, @logster_override_level_key="logster_override_level_9040">
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/rails.rb:62:in `block (2 levels) in <class:Rails>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq.rb:98:in `configure_server'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/rails.rb:53:in `block in <class:Rails>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:94:in `block in execute_hook'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:78:in `block in run_load_hooks'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:77:in `each'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/activesupport-7.1.1/lib/active_support/lazy_load_hooks.rb:77:in `run_load_hooks'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/application/finisher.rb:93:in `block in <module:Finisher>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:32:in `instance_exec'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:32:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:61:in `block in run_initializers'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.rubies/ruby-3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/initializable.rb:60:in `run_initializers'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/application.rb:423:in `initialize!'
20:21:31 sidekiq.1 | /Users/jioke/lab/projects/tcnabj-mvp-api/config/environment.rb:5:in `<top (required)>'
20:21:31 sidekiq.1 | <internal:/Users/jioke/.rubies/ruby-3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
20:21:31 sidekiq.1 | <internal:/Users/jioke/.rubies/ruby-3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/cli.rb:303:in `boot_application'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/lib/sidekiq/cli.rb:42:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/sidekiq-7.1.6/bin/sidekiq:31:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/sidekiq:25:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/sidekiq:25:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli/exec.rb:23:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:492:in `exec'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:34:in `dispatch'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/cli.rb:28:in `start'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/exe/bundle:45:in `block in <top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/gems/bundler-2.4.12/exe/bundle:33:in `<top (required)>'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/bundle:25:in `load'
20:21:31 sidekiq.1 | /Users/jioke/.gem/ruby/3.2.2/bin/bundle:25:in `<main>'
20:21:31 web.1     | Exiting
20:21:31 web.1     | /Users/jioke/.gem/ruby/3.2.2/gems/railties-7.1.1/lib/rails/commands/server/server_command.rb:83:in `log_to_stdout': undefined method `broadcast_to' for #<Logster::DeferLogger:0x0000000113a0b810 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000111a85518 @datetime_format=nil>, @formatter=nil, @logdev=nil, @store=#<Logster::RedisStore:0x0000000113a0be50 @max_retention=604800, @skip_empty=true, @allow_custom_patterns=false, @patterns_cache=#<Logster::Cache:0x0000000111a8a0e0 @age=2, @hash={}>, @redis=#<Redis client v5.0.7 for redis://localhost:6379/0>, @max_backlog=1000, @redis_prefix=nil, @redis_raw_connection=nil>, @chained=[#<ActiveSupport::BroadcastLogger:0x00000001111dbd90 @broadcasts=[#<ActiveSupport::Logger:0x0000000113ebd390 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000113ed9068 @datetime_format=nil>, @formatter=#<Logger::Formatter:0x0000000113ed6840 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x0000000113ebde30 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @binmode=false, @mon_data=#<Monitor:0x0000000113ed8e88>, @mon_data_owner_object_id=4760>, @local_level_key=:logger_thread_safe_level_8700>], @progname="Broadcast", @formatter=#<Logger::Formatter:0x0000000113ed6840 @datetime_format=nil>>], @skip_store=false, @logster_override_level_key="logster_override_level_8680"> (NoMethodError)
20:21:31 web.1     |
20:21:31 web.1     |           Rails.logger.broadcast_to(console)

I have no idea what I'm doing wrong. Any hints?

Not working in staging and production

Hi, I used Logster back in 2017 and love it. Using it again and it's working in dev but not prod or staging. While trying to troubleshoot it, I noticed two things:

  1. In the server logs I see that Logster is looking at different IPs. Is that normal?
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.71.159.45 at 2024-04-18 04:52:18 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.71.159.46 at 2024-04-18 04:52:30 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.71.159.45 at 2024-04-18 04:52:36 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.71.154.236 at 2024-04-18 04:53:15 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.71.154.194 at 2024-04-18 04:53:54 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 172.69.135.149 at 2024-04-18 04:54:33 +0000
Started GET "/logs/messages.json?filter=0_1_2_3_4_5" for 162.158.166.226 at 2024-04-18 04:55:12 +0000
  1. In dev, redis has many "logster-env-*" keys but none in staging.

Rails version is 4.2.9 (same app from 2017). I have this in Logster initializer:

Logster.set_environments(%i[local development qa staging production])
Logster.store = Logster::RedisStore.new

What am I doing wrong?

Thanks in advance!

Originally posted by @nahankid in #34 (comment)

Feature Request: Hide Lines Matching Pattern

Thanks for logster, it's very useful!

It would be great to have the ability to hide lines that match a pattern.

The first thing that this might be useful for is to hide the requests that logster itself makes. These add some noise and the autoscroll can take you away from where you left off.

Thanks,

Ben

screen shot 2014-05-05 at 2 50 08 am

Specify key namespace in Redis connection

It would be nice to specify a Redis key namespace. Something like this:

  redis_connection = Redis.new(host: Rails.application.config.redis_host, port: 6379, db: 0, driver: :hiredis, namespace: 'logster')
  Logster.store = Logster::RedisStore.new(redis_connection)

stack level too deep (SystemStackError)

Logs:

/home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:12:in block (2 levels) in broadcast': stack level too deep (SystemStackError) from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:inblock (2 levels) in broadcast'
from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:in block (2 levels) in broadcast' from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:inblock (2 levels) in broadcast'
from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:in block (2 levels) in broadcast' from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:inblock (2 levels) in broadcast'
from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:in block (2 levels) in broadcast' from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:inblock (2 levels) in broadcast'
from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/activesupport-4.2.6/lib/active_support/logger.rb:13:in block (2 levels) in broadcast' ... 4384 levels... from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /home/sahil/.rvm/gems/ruby-2.3.0@wms/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top (required)>' from bin/rails:4:inrequire'
from bin/rails:4:in `

'

Unable to use Logster with https://github.com/lulalala/multi_logger

I love Logster functionality but I can't use it with MultiLogger. I configured MultiLogger gem like this:

# config/initializers/multie_logger.rb
MultiLogger.add_logger('mylog')

But now I get these:
undefined method `mylog' for #Logster::Logger:0x00000009c11ae8

I tried this config Rails.logger.extend(ActiveSupport::Logger.broadcast(Logster.logger)) but no luck.

I am using Rails 4.1.14.2. Apologies if this is a really silly question but does anyone have suggestions?

Unable to set environments in application.rb

I've got logster to work in development and productions modes. Now I'm trying to get it to work in staging.

When I try set environments Logster.set_environments([:development, :staging, :production]) in application.rb I get this error on startup:

ERROR -- : undefined method environments=' for nil:NilClass (NoMethodError) /home/vagrant/.rvm/gems/ruby-2.0.0-p643/gems/logster-1.0.1/lib/logster.rb:45:inset_environments'

I am able to set store in application.rb though.

Cluster of servers serving the same application

Can Logster fetch logs from a cluster of servers serving the same application ? If one of my application servers has redis-server running, how would I configure Logster to listen to or post to that particular redis-server?

web-console gem conflict

After installing the logster gem, I was getting the following error:

$ rake middleware --trace
** Invoke middleware (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
No such middleware to insert before: ActionDispatch::DebugExceptions
/home/tirith/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/stack.rb:125:in `assert_index'
/home/tirith/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/stack.rb:88:in `insert'
...

The conflict ended up being with the web-console gem, rails app booted up fine w/ logster after removing it from the Gemfile. I don't really use web-console anyway, but figured in-case someone had it in their Gemfile and ran into the middleware issue, they would see this.

Thanks for this handy tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.