Commit 1056e215 authored by Dominik Charousset's avatar Dominik Charousset

Strip path of source files in logs

parent 50abe47a
...@@ -256,6 +256,9 @@ public: ...@@ -256,6 +256,9 @@ public:
/// @warning The returned vector can have pointers into `format_str`. /// @warning The returned vector can have pointers into `format_str`.
static line_format parse_format(const char* format_str); static line_format parse_format(const char* format_str);
/// Skips path in `filename`.
static const char* skip_path(const char* filename);
/// Returns a string representation of the joined groups of `x` if `x` is an /// Returns a string representation of the joined groups of `x` if `x` is an
/// actor with the `subscriber` mixin. /// actor with the `subscriber` mixin.
template <class T> template <class T>
...@@ -371,8 +374,8 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; } ...@@ -371,8 +374,8 @@ inline caf::actor_id caf_set_aid_dummy() { return 0; }
&& CAF_UNIFYN(caf_logger)->accepts(loglvl, component)) \ && CAF_UNIFYN(caf_logger)->accepts(loglvl, component)) \
CAF_UNIFYN(caf_logger) \ CAF_UNIFYN(caf_logger) \
->log(new ::caf::logger::event{ \ ->log(new ::caf::logger::event{ \
loglvl, component, CAF_PRETTY_FUN, __FILE__, __LINE__, \ loglvl, component, CAF_PRETTY_FUN, caf::logger::skip_path(__FILE__), \
(::caf::logger::line_builder{} << message).get(), \ __LINE__, (::caf::logger::line_builder{} << message).get(), \
::std::this_thread::get_id(), \ ::std::this_thread::get_id(), \
CAF_UNIFYN(caf_logger)->thread_local_aid(), \ CAF_UNIFYN(caf_logger)->thread_local_aid(), \
::caf::make_timestamp()}); \ ::caf::make_timestamp()}); \
......
...@@ -399,6 +399,11 @@ logger::line_format logger::parse_format(const char* format_str) { ...@@ -399,6 +399,11 @@ logger::line_format logger::parse_format(const char* format_str) {
return res; return res;
} }
const char* logger::skip_path(const char* path) {
auto ptr = strrchr(path, '/');
return ptr == nullptr ? path : (ptr + 1);
}
void logger::run() { void logger::run() {
#if defined(CAF_LOG_LEVEL) #if defined(CAF_LOG_LEVEL)
log_first_line(); log_first_line();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment