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

added rails-log as an 3rd-party language #2526

Closed
wants to merge 11 commits into from

Conversation

sweetppro
Copy link
Contributor

modified the ruby.js language to provide better syntax highlighting for Rails Unicorn logging.

sweetppro added 10 commits May 3, 2020 14:33
modified the ruby.js language to provide better syntax highlighting for Rails Unicorn logging.
fixed an issue with string definitions
improved string parsing
a modified ruby.js language definition to provide better syntax highlighting for Rails Unicorn logging.
@joshgoebel
Copy link
Member

I didn't look closely before. How is this different from Ruby?

Did you just add

  'Rendering Rendered Completed Started POST Processing by Redirected to Delivered mail Performed GET'

?

@joshgoebel
Copy link
Member

Why would there be raw Ruby code in the output of the Rails log? Like an exception?

@sweetppro
Copy link
Contributor Author

sweetppro commented May 3, 2020 via email

@joshgoebel
Copy link
Member

Theres a number of small regex tweaks which give a much better result in Unicorn logging

I'd be curious to see a diff against ruby.js... but this sounds like a pretty specific use case...

I was about to say with only the keywords you could do this with a few lines of code... (see arduino.js...)... but now I'm curious what these other tweaks might have been.

@sweetppro
Copy link
Contributor Author

here's an example:

I, [2020-05-03 13:57 #21962]  INFO -- : [c1bbbae9-2bcb] [0.0.0.0]   Rendered vendor/bundle/ruby/2.6.0/gems/exception_notification-4.4.0/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (Duration: 27.4ms | Allocations: 6416)
I, [2020-05-03 13:57 #21962]  INFO -- : [c1bbbae9-2bcb] [0.0.0.0] Delivered mail 5eaeb18edfdc_55ca2ada442f56546042e@lvps92-51-148-79.dedicated.hosteurope.de.mail (1729.9ms)
F, [2020-05-03 13:57 #21962] FATAL -- : [c1bbbae9-2bcb] [0.0.0.0]   
[c1bbbae9-2bcb] [0.0.0.0] ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
[c1bbbae9-2bcb] [0.0.0.0]   
[c1bbbae9-2bcb] [0.0.0.0] actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:217:in `handle_unverified_request'
[c1bbbae9-2bcb] [0.0.0.0] actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:249:in `handle_unverified_request'
[c1bbbae9-2bcb] [0.0.0.0] actionpack (6.0.2.2) lib/action_controller/metal/request_forgery_protection.rb:244:in `verify_authenticity_token'
[c1bbbae9-2bcb] [0.0.0.0] activesupport (6.0.2.2) lib/active_support/callbacks.rb:429:in `block in make_lambda'

@joshgoebel
Copy link
Member

joshgoebel commented May 3, 2020

So far it looks like the better/simpler choice might be to concentrate on parsing the log file itself and use the real Ruby as a sublanguage just for the relevant part of the stack trace.

@joshgoebel
Copy link
Member

joshgoebel commented May 3, 2020

If this is mostly/solely for unicorn I'm wondering if unicorn-rails-log might be more appropriate?

Thoughts?

We haven't had any name collisions yet, but I'm trying to plan ahead. Although I guess we could just list both and always let a person decide which to use. :)

@sweetppro
Copy link
Contributor Author

here's a diff:

rails-log.txt

@sweetppro sweetppro closed this May 3, 2020
@sweetppro
Copy link
Contributor Author

oops, closed accidentally

@sweetppro sweetppro reopened this May 3, 2020
@joshgoebel
Copy link
Member

What kind of diff is that? My editor doesn't like it one bit and won't color it.

@sweetppro
Copy link
Contributor Author

I created it like so:
git diff > rails-log.patch
then renamed it rails-log.txt to upload

@joshgoebel
Copy link
Member

Ok, wow most themes have terrible support for diffs in VS code. Annoying. :)

@joshgoebel
Copy link
Member

Yeah all these changes to work around line endings would probably have been better handled by Ruby as a sublanguage. And then only turn on the Ruby parsing for those parts of the line that are actually Ruby code. And the parent rule could always force the Ruby to end at the end of each line and then you wouldn't need to hack Ruby itself.

Any thoughts on the naming?

@sweetppro
Copy link
Contributor Author

I can change the name no problem.
I'll have another look in the morning, and see if I can figure out how to use Ruby as a sub language.

@joshgoebel
Copy link
Member

We have reasonable documentation and you can look at some of our grammars for samples... like XML can includes CSS and JS sublanguages, etc...

@sweetppro
Copy link
Contributor Author

nice one thx.
ill take a look

added unicorn-rails-log language repo
@sweetppro sweetppro changed the title added rails-log as an 3rd-party language added unicorn-rails-log as an 3rd-party language May 4, 2020
@sweetppro sweetppro changed the title added unicorn-rails-log as an 3rd-party language added rails-log as an 3rd-party language May 4, 2020
@sweetppro sweetppro closed this May 4, 2020
@sweetppro
Copy link
Contributor Author

new pull request here:
#2528

@joshgoebel
Copy link
Member

This PR would have still worked, but whatever. :) Thanks for contributing!

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

Successfully merging this pull request may close these issues.

2 participants