Skip to content
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

console log pretty #3180

Merged
merged 5 commits into from
Apr 15, 2024
Merged

console log pretty #3180

merged 5 commits into from
Apr 15, 2024

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Apr 3, 2024

This adds alternative way of printing mod log logs.

This change requires apache/mynewt-newt#551

New syscfg values that can be use to configure console printing

   # enable alternative mod log prints
    LOG_CONSOLE_PRETTY: 1
   # enable severity level coloring
    LOG_CONSOLE_PRETTY_WITH_COLORS: 1
   # disable time stamp
    LOG_CONSOLE_PRETTY_WITH_TIMESTAMP: 0

Old way of showing mod log logs:
image
New way:
image

@kasjer kasjer requested review from benmccrea and sjanc April 3, 2024 10:05
@kasjer kasjer force-pushed the kasjer/console-log-pretty branch from fd60bc2 to 512ae3f Compare April 4, 2024 07:58
@andrzej-kaczmarek
Copy link
Contributor

why not just LOG_CONSOLE_PRETTY?
I'd add an option to skip printing log level and e.g. colorize module name instead.
and perhaps an option to print timestamp as seconds, i.e. simply "0.123456" instead of "123456us".

@kasjer kasjer force-pushed the kasjer/console-log-pretty branch 2 times, most recently from f0ce919 to 231cf0e Compare April 9, 2024 13:33
@kasjer
Copy link
Contributor Author

kasjer commented Apr 9, 2024

@andrzej-kaczmarek updated as requested
image

Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, wait for newt commit so the checks will pass.

Current code had switch in function log_module_get_name()
that returned module name based on some syscfg value first
then it search modules registered by log_module_register().

Some of the syscfg values used in this code were referring
to be values that are not any syscfg.yml file.

Now code calls first auto-genereated function logcfg_log_module_name()
to get those names.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
DFLT_LOG has now log name specified in syscfg to keep "DEFAULT" as
default module log name.
Without this change name would be "DLFT"

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
This sets module name for logging to nicer values

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
console print was using series of hexadecimal formatting
without specifying filed size it could result in misleading
printout where leading zeros for each byte are missing.

Now format makes sure that all digits are present.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
This introduces alternative output of mod log header.
Log mod module was printed:
  mod=0
now it is displayed this way:
  [DEFAULT]
Log level used to be:
  level=2
Now it is:
  [WRN]
of nothing if color are requested

Time stamp is not displayed by default if CONSOLE_TICKS is 1

Severity level can be printed in color.

Additional syscfg values that can be used:
LOG_CONSOLE_PRETTY enable alternative display
LOG_CONSOLE_PRETTY_WITH_COLORS enables colors for severity level
LOG_CONSOLE_PRETTY_WITH_TIMESTAMP enables/disables time stamp printing

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
@kasjer kasjer merged commit a365cb1 into apache:master Apr 15, 2024
17 checks passed
@kasjer kasjer deleted the kasjer/console-log-pretty branch April 15, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants