Message ID | 20220401090309.2704921-1-kieran.bingham@ideasonboard.com |
---|---|
State | RFC |
Headers | show |
Series |
|
Related | show |
(^_^)/ Kieran, (^δΊΊ^) On Fri, Apr 01, 2022 at 10:03:09AM +0100, Kieran Bingham via libcamera-devel wrote: > Our debug logs are already growing terse and difficult to parse with the > eye. The specific notifications can easily blend into each other. > > Add some highlight and colour to the log messages by replacing > the log severity levels with emoji characters which convey > the same meaning but in much less space. > > Syslog and output to files remains unchanged. Only stream outputs > display emoji symbols. o_0 ... (^β^) ! > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/base/log.cpp | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp > index 64813b6607c5..aceec7302549 100644 > --- a/src/libcamera/base/log.cpp > +++ b/src/libcamera/base/log.cpp > @@ -96,6 +96,23 @@ static const char *log_severity_name(LogSeverity severity) > return "UNKWN"; > } > > +static const std::string &log_severity_emojis(LogSeverity severity) > +{ > + static const std::string emojis[] = { > + "πͺ² ", // DEBUG > + "βΉοΈ ", // INFO > + "β οΈ ", // WARNING > + "π₯ ", // ERROR > + "π ", // FATAL > + "π€ ", // Unknown β (Γ_Γ) > + }; > + > + if (static_cast<unsigned int>(severity) < std::size(emojis)) > + return emojis[severity]; > + else > + return emojis[std::size(emojis) - 1]; > +} > + > /** > * \brief Log output > * > @@ -194,7 +211,6 @@ void LogOutput::write(const LogMessage &msg) > + msg.msg(); > writeSyslog(msg.severity(), str); > break; > - case LoggingTargetStream: > case LoggingTargetFile: > str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" > + std::to_string(Thread::currentId()) + "] " > @@ -203,6 +219,13 @@ void LogOutput::write(const LogMessage &msg) > + msg.msg(); > writeStream(str); > break; > + case LoggingTargetStream: > + str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" > + + std::to_string(Thread::currentId()) + "] " > + + log_severity_emojis(msg.severity()) + " " > + + msg.category().name() + " " + msg.fileInfo() + " " > + + msg.msg(); > + writeStream(str); > default: > break; > }
Hello, That's a perfect patch for friday :-D On 4/1/22 14:33, Kieran Bingham via libcamera-devel wrote: > Our debug logs are already growing terse and difficult to parse with the > eye. The specific notifications can easily blend into each other. > > Add some highlight and colour to the log messages by replacing > the log severity levels with emoji characters which convey > the same meaning but in much less space. > > Syslog and output to files remains unchanged. Only stream outputs > display emoji symbols. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Nice to have surely, Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > --- > src/libcamera/base/log.cpp | 25 ++++++++++++++++++++++++- > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp > index 64813b6607c5..aceec7302549 100644 > --- a/src/libcamera/base/log.cpp > +++ b/src/libcamera/base/log.cpp > @@ -96,6 +96,23 @@ static const char *log_severity_name(LogSeverity severity) > return "UNKWN"; > } > > +static const std::string &log_severity_emojis(LogSeverity severity) > +{ > + static const std::string emojis[] = { > + "πͺ² ", // DEBUG > + "βΉοΈ ", // INFO > + "β οΈ ", // WARNING > + "π₯ ", // ERROR > + "π ", // FATAL > + "π€ ", // Unknown > + }; > + > + if (static_cast<unsigned int>(severity) < std::size(emojis)) > + return emojis[severity]; > + else > + return emojis[std::size(emojis) - 1]; > +} > + > /** > * \brief Log output > * > @@ -194,7 +211,6 @@ void LogOutput::write(const LogMessage &msg) > + msg.msg(); > writeSyslog(msg.severity(), str); > break; > - case LoggingTargetStream: > case LoggingTargetFile: > str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" > + std::to_string(Thread::currentId()) + "] " > @@ -203,6 +219,13 @@ void LogOutput::write(const LogMessage &msg) > + msg.msg(); > writeStream(str); > break; > + case LoggingTargetStream: > + str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" > + + std::to_string(Thread::currentId()) + "] " > + + log_severity_emojis(msg.severity()) + " " > + + msg.category().name() + " " + msg.fileInfo() + " " > + + msg.msg(); > + writeStream(str); > default: > break; > }
diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 64813b6607c5..aceec7302549 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -96,6 +96,23 @@ static const char *log_severity_name(LogSeverity severity) return "UNKWN"; } +static const std::string &log_severity_emojis(LogSeverity severity) +{ + static const std::string emojis[] = { + "πͺ² ", // DEBUG + "βΉοΈ ", // INFO + "β οΈ ", // WARNING + "π₯ ", // ERROR + "π ", // FATAL + "π€ ", // Unknown + }; + + if (static_cast<unsigned int>(severity) < std::size(emojis)) + return emojis[severity]; + else + return emojis[std::size(emojis) - 1]; +} + /** * \brief Log output * @@ -194,7 +211,6 @@ void LogOutput::write(const LogMessage &msg) + msg.msg(); writeSyslog(msg.severity(), str); break; - case LoggingTargetStream: case LoggingTargetFile: str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" + std::to_string(Thread::currentId()) + "] " @@ -203,6 +219,13 @@ void LogOutput::write(const LogMessage &msg) + msg.msg(); writeStream(str); break; + case LoggingTargetStream: + str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" + + std::to_string(Thread::currentId()) + "] " + + log_severity_emojis(msg.severity()) + " " + + msg.category().name() + " " + msg.fileInfo() + " " + + msg.msg(); + writeStream(str); default: break; }
Our debug logs are already growing terse and difficult to parse with the eye. The specific notifications can easily blend into each other. Add some highlight and colour to the log messages by replacing the log severity levels with emoji characters which convey the same meaning but in much less space. Syslog and output to files remains unchanged. Only stream outputs display emoji symbols. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- src/libcamera/base/log.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)