-
Notifications
You must be signed in to change notification settings - Fork 145
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
Honeybadger.logger
(semantic logger)
#462
Conversation
f9f40fc
to
29a9ced
Compare
29a9ced
to
614b699
Compare
I've played with this a bit, and here are some changes I want to make:
if (url = ENV["HONEYBADGER_LOGGING_URL"]).present?
Honeybadger::Logger.create(url: url)
ActiveSupport::Notifications.subscribe("process_action.action_controller") do |name, started, finished, unique_id, payload|
Honeybadger::Logger.log(payload: payload.slice(:controller, :action, :params, :format, :method, :path, :status, :view_runtime, :db_runtime).merge({event: name}))
end
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. |
7d6be9e
to
653fdde
Compare
653fdde
to
7e1c2a3
Compare
Updated according to your requirements (the username and password being in the URL is effectively the same as the Basic Auth, which is already in place). Some UX thoughts:
|
I agree that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me, thought I want to leave this on a branch for now. We might want to change the namespace, as you noted.
5656b13
to
bf59d10
Compare
Cool, I've added (Btw, implementation note: since we're using the existing Server backend, the logs are sent compressed with Zlib, same as errors.) Also, I realised that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but since the logging URL will likely be at a different domain — that is, it won't be api.honeybadger.io — wouldn't it be better to not use the backend's notify method to send the payload?
Ah, I didn't know this. |
I'm sorry, I should have been clear about that earlier. This is one reason why I suggested using SemanticLogger, which has a HTTPS transport. |
This reverts commit 1bda33d.
3c1a584
to
f08e8c4
Compare
FYI, I might be changing my mind on the endpoint... it may be api.honeybadger.io/v1/events after all. :) |
Closing this because we decided to go a different direction. We'll implement the logger API after #512. |
First pass at implementing
Honeybadger.logger
with Semantic Logger. Notes:This won't work reliably until the bug with plugin loading is fixed. (Plugin loading limitation #461 )
With this approach,
Honeybadger.logger
is always available, and will send logs directly to Honeybadger. It does not need to be enabled via any config. (This also meanssemantic_logger
becomes a dependency).With the config setting
semantic_logger.enabled
, we will auto-add the HB appender to the user's SemanticLogger config, allowing the user to log via their app logger, or via Semantic Logger directly.For Rails, the user has to install
rails_semantic_logger
if they want the auto-add feature. I'm skeptical of implementing the ActiveSupport notifications subscription ourselves because I feel it would be re-implementing what SL already does, which is (by the maintainer's admission) a hack. (I even had to tweak some of my local Rails to get SL to work properly.) I think it's better the user rely on the hack with more experience.We could handle the subscriptions part fairly easily, but we'd also have to replace the Rails logger, which is difficult to do consistently without introducing some unexpected behaviour for users. For instance, simply reassigning
Rails.logger
would mean an event would get logged twice, once by the default Rails subscriber in a non-semantic format, and once by ours. And we'd have to maintain an stdout or stderr output for the user as well, and provide a way for them to specify the desired format, etc.