The log target is a string that can be fully customized. Before this PR, this field is not used in spdlog-rs. Actually it can be used as a way to announce the logger name when you want to emit logs in a library through the log crate. Thus, in this PR, I used this information as another source of logger names.
Specifically, when constructing a spdlog::Record from a log::Record with a specific spdlog::Logger: (see also source)
If the spdlog::Logger has a logger name configured, the logger name of the constructed spdlog::Record will be that name.
Otherwise, if the log::Record has a non-empty target, the logger name of the constructed spdlog::Record will be that value.
Otherwise, the logger name of the constructed spdlog::Record will be None.
API Breaking
This PR indeed has potential impacts. It's actually API breaking because the signature of spdlog::Record::logger_name is updated from:
. This is because we have to change the way we store the logger name in spdlog::Record. Before this PR, the logger name is simply represented by a &'a str. In this PR, I need to update its type to Cow<&'a, str> because I have to store an owned version of the log target name if the record is constructed from a log crate record.
But I believe the impact of this change should be minimal.
The
log
crate support specifying log target in the syntax below:The log target is a string that can be fully customized. Before this PR, this field is not used in spdlog-rs. Actually it can be used as a way to announce the logger name when you want to emit logs in a library through the
log
crate. Thus, in this PR, I used this information as another source of logger names.Specifically, when constructing a
spdlog::Record
from alog::Record
with a specificspdlog::Logger
: (see also source)spdlog::Logger
has a logger name configured, the logger name of the constructedspdlog::Record
will be that name.log::Record
has a non-emptytarget
, the logger name of the constructedspdlog::Record
will be that value.spdlog::Record
will beNone
.API Breaking
This PR indeed has potential impacts. It's actually API breaking because the signature of
spdlog::Record::logger_name
is updated from:to:
. This is because we have to change the way we store the logger name in
spdlog::Record
. Before this PR, the logger name is simply represented by a&'a str
. In this PR, I need to update its type toCow<&'a, str>
because I have to store an owned version of the log target name if the record is constructed from a log crate record.But I believe the impact of this change should be minimal.