Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve server-side logging options #264

Closed
leastbad opened this issue Jul 7, 2020 · 1 comment · Fixed by #337
Closed

Improve server-side logging options #264

leastbad opened this issue Jul 7, 2020 · 1 comment · Fixed by #337
Labels

Comments

@leastbad
Copy link
Contributor

leastbad commented Jul 7, 2020

Feature Request

It would be nice if StimulusReflex offered better logging tooling that was comfortably in-between "way too verbose" and "totally suppressed".

Is your feature request related to a problem?

@marcoroth recently added amazing client-side logging, but we offer no SR-specific feedback unless there's literally an excpetion. This leads to lots of puts statements in Reflexes while debugging. We can do better!

Describe the solution you'd like

The ideal solution emits one tastefully colored line per Reflex action.

Some possible columns include:

ReflexClass#action eg. Example#hello
Timestamp: eg. Time.now
Round-trip execution time eg 8ms
Session Identifier: eg. [215a1c85]
Connection Identifier from AC channel: eg. leastbad
Mode: eg. :selector
Selector: eg. #notification
Operation: eg. (selector: #notification)

Dream output

[215a1c85] Example#hello in 8ms (selector: #notification) for "leastbad" at 2020-07-07 15:04:13

... but in color.

Bonus points for being configurable via an initializer:

# config/initializers/stimulus_reflex.rb
StimulusReflex.configure do |config|
  # config.logging = :nil
  config.logging = [:session, :reflex, :benchmark, :operation, :identifier, :timestamp]
end

Additional context

The current options are two extremes: https://docs.stimulusreflex.com/troubleshooting#server-side

Adding an initializer is long overdue! Here's how:

  class << self
    mattr_accessor :logging
    self.logging = [] # this is the default, even if there is no initializer
  end

  def self.configure(&block)
    yield self
  end

Colors!

puts "\e[32mThis is green!"

puts "\e[1;32mThis is bright green!"

9UVnC

@piotrwodz
Copy link
Contributor

@leastbad Recently I worked on a server-side logging per reflex action. As a result debugging in development feels more friendly 👍 The guidelines defined in this issue were helpful. Thanks for that. There is a linked PR where you can find an overview of my solution. Give it a go, please! 🏎️ + 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants