Commit Graph

15 Commits

Author SHA1 Message Date
Frediano Ziglio
4b0c25823f log: Remove spice_printerr macro
All usages of this macro were removed.
A library should not log to standard error but use log facilities
so remove this macro to avoid possible future usage.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-29 19:02:21 +01:00
Frediano Ziglio
4c2d0e9772 Add --enable-extra-checks option
Allow to enable code to do additional or expensive checks.
The option should be used by higher level libraries.
By default the option is disabled.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2018-03-19 14:47:21 +00:00
Frediano Ziglio
eeab433539 log: Force format in log macro to be a string
Make sure format is a string and not a pointer.
This prevents usages like:

  spice_debug(NULL);

This forbids computed format strings, but on the other hand, forcing
the use of string constants allows the compiler to always check
argument types against the format string. Moreover, there is no
occurrences of computed format strings in the current codebase.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:10 +01:00
Frediano Ziglio
518c57db20 log: Forbid the usage of obsolete SPICE_LOG_DOMAIN
As we decided to not use multiple GLib domains, the SPICE_LOG_DOMAIN
macro is not really useful. This commit removes it.
Will be replaced by some different categorization.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:02 +01:00
Frediano Ziglio
dde1fe3533 log: remove spice_static_assert macro
The macro was misused and not doing static check.
Spice have other working static check macros to use.
The macro is used only by spice-common so removing it
does not cause issues to other depending projects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
1d7acdcf57 log: Use GLib logging levels directly
As we moved toward GLib logging instead of having to convert
every time the log level from the old system to GLib use
directly GLib constants.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-09 09:46:35 +01:00
Christophe Fergeau
af682b1b06 log: Follow spice style guidelines for #include in log.h
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-31 12:14:02 +02:00
Christophe Fergeau
0996c33d6d log: Add missing stdio.h include
This is needed because spice_printerr uses fprintf/stderr

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 10:37:28 +01:00
Christophe Fergeau
0a6580d2e6 log: Kill spice_warn_if
It's redundant with spice_warn_if_fail(), and can even be confusing.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 15:58:43 +01:00
Christophe Fergeau
efd1d3cb4d log: Use glib for logging
spice-common has been duplicating glib logging methods for a long while.
Now that spice-common is depending on glib, it's more consistent to use
glib logging too. However, the code base is still using spice logging
functions.
This commit aims to make spice logging go through glib logging system,
while keeping the same behaviour for the SPICE_ABORT_LEVEL and
SPICE_DEBUG_LEVEL environment variables. They are deprecated however in
favour of the glib alternatives (G_DEBUG and G_MESSAGES_DEBUG).

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 15:58:43 +01:00
Christophe Fergeau
2ff25b7567 log: Remove unneeded #ifdef/#endif
If header guards are working as expected, there should not be multiple
definitions of these macros. If they are redefined somewhere else, this
is a bug we want to fix.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-26 11:49:14 +01:00
Christophe Fergeau
838596a257 log: Use more glib macros
No need to have our own SPICE_STMT_BEGIN/END and SPICE_STRINGIFY

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-01-21 11:10:39 +01:00
Alon Levy
2449260c81 common/log.h: add spice_info 2012-07-05 19:22:31 +03:00
Daniel P. Berrange
985ec9d6ec Add printf format annotations to all '...' functions
To allow the compile to detect incorrect printf formats, any
var-args function should have a format annotation

* common/macros.h: Helper to define ATTR_PRINTF for code
  which can't depend on glib
* common/canvas_base.c, common/lz.h, common/macros.h: Annotate
  some var-args methods
2012-03-20 15:30:24 +01:00
Marc-André Lureau
c1403ee6bf Use a log handler to modify abort() behaviour
Be more library friendly, by not aborting in library errors.

spice_common now includes a proper log handler that will abort by
default when reaching a warning.

SPICE_ABORT_LEVEL can be changed to modify run-time abort level.

SPICE_DEBUG_LEVEL can be changed to be more verbose. By default, only
log level more importants than WARNING.

Only memory-related functions are allowed to abort(), since they are
not recoverable errors in the library.
2012-03-20 15:30:23 +01:00