Opened 5 years ago

Closed 5 years ago

#1269 closed defect/bug (fixed)

Android: all log messages appear as errors in logcat

Reported by: mvglasow (2) Owned by: KaZeR
Priority: major Milestone:
Component: core Version: git master
Severity: normal Keywords:
Cc:

Description

Apparently anything that Navit logs on Android shows up as "error" in the logcat, even status messages. They should be mapped to the appropriate category (debug, information, warning etc.)

Change History (3)

comment:1 follow-up: Changed 5 years ago by mvglasow (2)

Looking at debug_vprintf() in debug.c, it seems that the approach "any message is an error" is being followed consistently across all platforms (e.g. Windows displays all message boxes with a red X). Still, we should separate messages into categories:

  • Error: An operation could not be carried out.
  • Warning: An error condition was successfully fixed and the operation can proceed, although limitations are possible (e.g. the map was rendered but some icons may be missing).
  • Information: Status information, such as successful completion of a user-initiated operation.
  • Debug: Information about the internal state of Navit. Anything that the end user would not worry about would go here.

The difficulty is to map dbg() calls to categories. The first argument indicates the log level, but even the lowest level (0) seems to be used for messages I would place in the Debug category.

Should we clean that up by strictly mapping debug levels to severity (0=error, 1=warning, 2=info, 3=debug)? Or should we introduce a separate severity parameter into dbg()?

comment:2 in reply to: ↑ 1 Changed 5 years ago by sleske

Replying to http://wiki.navit-project.org/index.php/user:mvglasow (2):

The difficulty is to map dbg() calls to categories. The first argument indicates the log level, but even the lowest level (0) seems to be used for messages I would place in the Debug category.

Should we clean that up by strictly mapping debug levels to severity (0=error, 1=warning, 2=info, 3=debug)? Or should we introduce a separate severity parameter into dbg()?

I think the log level should be the severity - it's just used very inconsistenly in Navit. I've been planning for a long time to introduce sensible log levels - something like what you indicate above.

A simple solution would be to just introduce an enum for the log levels (ERROR,WARN,INFO,DEBUG), and use that consistently. Initially that would just be a big search&replace job, then we could slowly clean up the logging statements to use sensible severities (a lot of the logging code needs a cleanup anyway).

If there are no objections, I'll probably get started soon :-).

comment:3 Changed 5 years ago by sleske

  • Resolution set to fixed
  • Status changed from new to closed

It took some time, but I'm done now :-).

Changes:

  • dbg() now takes an enum as its first parameter: dbg_level. Values: lvl_error, lvl_warning, lvl_info, lvl_debug. All calls to dbg() have been changed.
  • Since most calls to dbg used level 0 or 1, I changed all these to lvl_debug, unless the message looked like an error message. Further cleanup is probably necessary.
  • Logging on Android now maps these levels to the appropriate Android log levels. So logs should look nicer now.

Also, some associated fixes:

  • The debug level is included in the standard debug output.
  • The help for -d has been updated.
  • The textual log levels can now be used in navit.xml; navit_shipped.xml has been updated accordingly (the change is backward-compatible).

I hope logging is more useful now. Committed in r5960 to r5969.

Note: See TracTickets for help on using tickets.