-
Notifications
You must be signed in to change notification settings - Fork 37
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
Logging sources #502
Logging sources #502
Conversation
Main benchmark PR benchmark Keep in mind, these numbers are not representative of LavinMQ's peak performance. |
30bd9bf
to
1fdb20e
Compare
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.
LGTM!
Wondering if the |
What is this new |
|
Maybe not, I just think it's nice to be explicit. Also, if you want debug for lavinmq code but not libraries you must specify a level for each of the libraries too. |
@carlhoerberg wdyt? |
@@ -12,10 +12,12 @@ module LavinMQ | |||
include Stats | |||
include SortableJSON | |||
|
|||
Log = Client::Log.for "channel" |
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.
Is this still needed?
Log = Client::Log.for "channel" |
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.
It's used by the EntityLog
for Channel
, and also by Consumer
.
Following the docs/"pattern" for Log
, declaring a Log
per namespace seems to be the way to go. Sticking to always declaring Log
in module/class makes it consistent on where source
is set. I have no real opinion on this. Also, as I mention in the other comment, I thought it would create a new Log
instance for every for
call.
|
||
module LavinMQ | ||
class Client | ||
class Channel | ||
class Consumer | ||
include SortableJSON | ||
|
||
Log = Channel::Log |
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.
what is this used by?
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.
It's declared here to show that Consumer
has the same log source as Channel
. It's then used by each Consumer
's EntityLog
.
|
||
def initialize(@vhost : VHost) | ||
@log = Log.for "UpstreamStore[vhost=#{@vhost}]" | ||
@log = @vhost.log.extend(Log) |
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.
why not?
@log = @vhost.log.extend(Log) | |
@log = @vhost.log.extend(Federation::Log.for "upstreamstore") |
Isn't there a risk that someone starts to use Log
in the class otherwise? and/or that the Log = Federation::Log.for "upstreamstore"
is removed because it's not used except here, but kind of implicitly.
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.
Yes, absolutely.
IIRC the reason for setting Log
and use that was that I assumed that Log.for
would create a new Log
instance for every call. Now that I've read the code and I see that it's not, this could be changed.
e21dfdc
to
fe0b7ef
Compare
fe0b7ef
to
aac7a52
Compare
The Queue::Log instnance is wrapped and vhost name and queue name is passed as metadata to all log entries instead of being a part of the log source.
Make it easier to use Log constans, step by step.
- Use class constant Log as "base" for all logging. - Wrap some Log in EntityLog to "tag" entries
Queue, Exchange and Client are all subentities to vhost.
... to get rid of editor warnings
aac7a52
to
11984c3
Compare
@tls_context : OpenSSL::SSL::Context::Server? | ||
@first_shutdown_attempt = true | ||
@data_dir_lock : DataDirLock? | ||
@log_setup = false |
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.
doens't seem to be used
@log_setup = false |
::Log.setup_from_env( | ||
backend: Log::IOBackend.new( | ||
formatter: LavinMQ::Logging::StdoutLogFormat)) |
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.
means that we get logs in specs, in systemd environments etc with wrong format?
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.
Dunno what you mean with wrong format? It's the same formatter as will be used again when the log is configured from config.
I don't recall exactly why I added this, but it's to have a "default logger" configured before we've parse the config.
Move extend method to Log::Metadata to make it more efficient. This will reduce the need of temporary hashes when creating the new Metadata.
Closing this for now. We're probably not going with it. |
Refactor logging to embrace Crystal's Log pattern with sources.
Instead of adding e.g. entity name to the source it will be appended as metadata in all entries.
New configuration section
log_levels
:If
log_levels
is usedlog_level
inmain
section won't have any effect.Sources: