Commit Graph
31 Commits
Author SHA1 Message Date
Aleksander Morgado bb310526dc core, log: make libraries logging use the MM level and format
The log level of the libraries was not honoring the log level
configured in MM, so we would see debug messages reported even if the
default log level configured was INFO or MSG.

The format of the logs emitted by the libraries was also not following
the format of the rest of MM logs, e.g. they would not include timing
info in the logs which would make it hard to follow certain event
transitions.

Make the libraries logging use the ModemManager logging method, to fix
all those issues.
2022-08-05 17:11:34 +02:00
Aleksander Morgado 4cb8ca8f0b core,log: minor coding style changes 2022-08-05 17:11:31 +02:00
som 1e08f9ca2c mm-log: hiding personal info while logging
During mm logging, some of the information like simIccId, Telephone
numbers need to be hidden from displaying in the logs to protect
some of the user information.

Implemented for MBIM requiring libmbim 1.27.6, which is the
development version that includes the needed API.
2022-04-20 15:20:34 +02:00
Aleksander Morgado 268cab885b core: drop "volatile" for g_once_init_enter locations
This fixes a few (fatal in gcc 11) warnings.

See https://gitlab.gnome.org/GNOME/glib/-/issues/600
2021-05-18 11:28:18 +02:00
Andrew Lassalle 5a9460b355 log: enable QRTR logging
Add the 'Qrtr' domain so logging from libqrtr is enabled.
2021-04-14 11:27:27 +02:00
Aleksander Morgado a31d762250 log: ignore fatal flag for logging purposes
Running with G_DEBUG=fatal-warnings will end up reporting warning logs
with G_LOG_FLAG_FATAL, which breaks our own logging logic.
2020-10-25 21:38:01 +01:00
Aleksander Morgado 997e2cefb8 log: define per-module logging for shared utils and plugins 2020-04-08 17:53:42 +02:00
Aleksander Morgado e956bac47b log: common logging method definition for all testers and helpers 2020-04-08 17:53:42 +02:00
Aleksander Morgado 9bcadea172 log: new object logging support
So that we can provide the specific object id in every log associated
to a given object.
2020-04-08 16:35:08 +02:00
Aleksander Morgado b087549c7d core,log: fix warnings with -Wswitch-enum
mm-log.c: In function ‘glib_to_syslog_priority’:
  mm-log.c:99:5: warning: enumeration value ‘G_LOG_FLAG_RECURSION’ not handled in switch [-Wswitch-enum]
     99 |     switch (level) {
        |     ^~~~~~
  mm-log.c:99:5: warning: enumeration value ‘G_LOG_FLAG_FATAL’ not handled in switch [-Wswitch-enum]
  mm-log.c:99:5: warning: enumeration value ‘G_LOG_LEVEL_INFO’ not handled in switch [-Wswitch-enum]
  mm-log.c:99:5: warning: enumeration value ‘G_LOG_LEVEL_MASK’ not handled in switch [-Wswitch-enum]
2020-01-30 11:59:14 +01:00
Aleksander Morgado b024381be5 core,log: fix warnings with -Wswitch-default
mm-log.c: In function ‘mm_to_syslog_priority’:
  mm-log.c:82:5: warning: switch missing default case [-Wswitch-default]
     82 |     switch (level) {
        |     ^~~~~~

  mm-log.c: In function ‘log_level_description’:
  mm-log.c:118:5: warning: switch missing default case [-Wswitch-default]
    118 |     switch (level) {
        |     ^~~~~~
2020-01-30 11:59:14 +01:00
Ben Chan 5263ec650f log: minor coding style fixes 2017-07-17 13:46:14 -05:00
Torsten Hilbrich fd0bed1df9 log: Add support for journal logging
This logging is available if the software was build with the configure
option --with-systemd-journal.

It will be enabled by default if libsystemd is found.

The runtime parameter --log-journal enables to output of log messages
to the systemd journal.

Please note that the journal priority field has the same value as the
syslog level so no conversion is required here.
2017-06-21 13:08:17 +02:00
Torsten Hilbrich 13592c5d2d log: Introduce function pointer to handle different log backends
This allows for easier additions of other logging mechanism.

Using the syslog loglevel as parameter because we need to be able to
map the MMLogLevel and the GLogLevelFlags to a common representation
when using the log_backend in _mm_log and log_handler.

The syslog level is more suitable because it supports more values than
the MMLogLevel.
2017-06-21 13:06:23 +02:00
Torsten Hilbrich 7917c85c6b log: Add mapping from glib loglevel to syslog priority
Improves readability of log_handler function.
2017-06-21 13:05:27 +02:00
Torsten Hilbrich 9160f4e350 log: Refactor log level text output
Adding a helper function to turn the log level into the text. Also
add an internal flag to disable this output. This flag will become
useful when adding systemd journal support.
2017-06-21 13:04:24 +02:00
Torsten Hilbrich b4ad1e8a21 log: Refactor evaluation of log level
Starting with adding a typed enum type for the log level named
MMLogLevel.

Suggested-By: Aleksander Morgado <aleksander@aleksander.es>

The level was checked twice in _mm_log. Once at the beginning and
again when turning the level into both the syslog priority and some
descriptive text which was added to the log level. Removing the check
at the second location as it was redundant.

Also adding a helper function to turn the MMLogLevel into the syslog
equivalent. This will become handy when adding support for systemd
journal.
2017-06-21 13:02:39 +02:00
Aleksander Morgado 57f193bd04 log: remove func loc info unless MM_LOG_FUNC_LOC is defined
The user can build the project passing custom CFLAGS to enable the
function location information, e.g.:

    $ ./configure --prefix=/usr CFLAGS="-DMM_LOG_FUNC_LOC"
2017-05-29 13:42:23 +02:00
Dan Williams 27e1936277 core: rework logging code to remove log message truncation (bgo #698312)
Use a static GString which will resize itself if the log message
is bigger than the current string size, but will also ensure we
don't do a ton of memory reallocation on every log message.

Previously all log messages were trucated at 512 bytes due to the
log buffer char array being 512 bytes long.
2013-04-18 11:23:57 -05:00
Aleksander Morgado 12d6e59c86 log: enable MBIM traces if running in debug mode 2013-04-17 15:19:38 +02:00
Dan Williams 2d700043ab core: use g_unix_signal_add() for more reliable Unix signal handling
There were a few problems with MM's existing signal handling, first
of which was that calling g_main_loop_quit() from a signal handler
only works 50% of the time due to severe restrictions on what you
can do from the handler.  This caused INT or TERM to sometimes be
ignored by MM.

Instead, use the glib signal functions which ensure that the handler
is run in the right context, where we can do anything we want.
2013-02-12 15:48:39 -06:00
Aleksander Morgado 120b660fd4 core,log: include logging from the 'Qmi' log domain
Sync with libqmi:

commit 2835a53732fdae32478dd954a9ee3fa8afd93cab
Author: Aleksander Morgado <aleksander@lanedo.com>
Date:   Tue Oct 30 15:02:24 2012 +0100

    libqmi-glib: define library G_LOG_DOMAIN
2012-10-30 16:06:27 +01:00
Aleksander Morgado f1bcc531a3 log: enable QMI traces when showing debug logs
Use the new `qmi_utils_set_traces_enabled()' to specify that we want QMI traces
when running with DEBUG logs.

Sync with libqmi:

commit 35dcb4bb6ed2755d968cf97d69faff9ed5f6871f
Author: Aleksander Morgado <aleksander@lanedo.com>
Date:   Tue Oct 9 13:44:16 2012 +0200

    libqmi-glib: message traces compiled always

    Message traces have been very useful when debugging issues in the protocol, and
    we should avoid requiring a full recompilation in order to get them enabled.

    Instead, we provide two new API methods, `qmi_utils_(get|set)_traces_enabled()',
    which allow specifying whether traces should be dumped with g_debug() or not.
2012-10-09 16:28:46 +02:00
Aleksander Morgado 181f9c85f0 log: only include LOC and method name in debug logs if running with --debug
If the modem is started with --log-level=DEBUG, they will not be shown.
2012-03-16 14:53:23 +01:00
Aleksander Morgado c58db4e015 core: start using our newly defined errors 2012-03-15 14:14:25 +01:00
Nathan Williams 1b73fa1541 Add a DBus interface for setting the log level.
Lifted almost entirely from similar code in NetworkManager.

BUG=chromium-os:15197
TEST='dbus-send --print-reply --system --dest=org.freedesktop.ModemManager /org/freedesktop/ModemManager org.freedesktop.ModemManager.SetLogging string:DEBUG'
Also try valid log levels 'ERR', 'WARN', 'INFO', and an invalid log level, such as 'ABCDE'.

Change-Id: I2bddcd0319f4966dd293b119f68e7cc1697949b7
Reviewed-on: http://gerrit.chromium.org/gerrit/3134
Tested-by: Nathan J. Williams <njw@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
2011-06-30 12:25:02 -05:00
Michael Biebl 871097327b logging: use glong for secs and usecs 2011-02-25 18:21:52 -06:00
Dan Williams 7707117862 log: fix spacing so messages line up 2011-02-25 11:18:55 -06:00
Dan Williams 245b893e98 logging: make gcc 4.4.3 happy about ignored unused results 2011-01-24 14:13:28 -06:00
Dan Williams 98ec26283a logging: shut up compiler warnings about unused result from write(2)
We actually don't care about the result here.  But we do in other
places, so we want to keep the warning in general.
2011-01-24 14:05:07 -06:00
Dan Williams 16039244bb core: rework logging
Make it more flexible, add logging to a file, and absolute and
relative timestamps.
2011-01-23 20:51:48 -06:00