[-]
[+]
|
Changed |
_service:tar_git:libglibutil.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,8 +6,8 @@
<service name="tar_git">
<param name="url">https://git.sailfishos.org/mer-core/libglibutil.git</param>
<param name="branch">master</param>
- <param name="revision">HEAD</param>
+ <param name="revision">c8ca000b23491dbae8c3bee225c9c1621308657a</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
-</service></services>
\ No newline at end of file
+</service></services>
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/Makefile
^
|
@@ -20,7 +20,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 41
+VERSION_RELEASE = 43
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,17 @@
+libglibutil (1.0.43) unstable; urgency=low
+
+ * Allow specifying per-module logging function
+ * Added default GLogProc2 compatible callbacks
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 20 Dec 2019 19:31:32 +0200
+
+libglibutil (1.0.42) unstable; urgency=low
+
+ * Zero-initialize timespec::tv_nsec
+ * Optimized gutil_strv_equal()
+
+ -- Slava Monich <slava.monich@jolla.com> Fri, 22 Nov 2019 00:49:13 +0200
+
libglibutil (1.0.41) unstable; urgency=low
* Added gutil_bytes_equal() and gutil_bytes_equal_data()
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/include/gutil_log.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2019 Jolla Ltd.
+ * Copyright (C) 2014-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -75,11 +75,19 @@
# endif
#endif
+/* Logging function prototypes */
+#define GUTIL_DEFINE_LOG_FN(fn) void fn(const char* name, int level, \
+ const char* format, va_list va)
+#define GUTIL_DEFINE_LOG_FN2(fn) void fn(const GLogModule* module, \
+ int level, const char* format, va_list va)
+typedef GUTIL_DEFINE_LOG_FN((*GLogProc));
+typedef GUTIL_DEFINE_LOG_FN2((*GLogProc2));
+
/* Log module */
struct glog_module {
const char* name; /* Name (used as prefix) */
const GLogModule* parent; /* Parent log module (optional) */
- void* reserved; /* Reserved for future expansion */
+ GLogProc2 log_proc; /* Per-module logging function (1.0.43) */
const int max_level; /* Maximum level defined at compile time */
int level; /* Current log level */
int flags; /* Flags (see below) */
@@ -145,19 +153,17 @@
extern const char GLOG_TYPE_SYSLOG[];
/* Available log handlers */
-#define GUTIL_DEFINE_LOG_FN(fn) void fn(const char* name, int level, \
- const char* format, va_list va)
-#define GUTIL_DEFINE_LOG_FN2(fn) void fn(const GLogModule* module, \
- int level, const char* format, va_list va)
GUTIL_DEFINE_LOG_FN(gutil_log_stdout);
GUTIL_DEFINE_LOG_FN(gutil_log_stderr);
GUTIL_DEFINE_LOG_FN(gutil_log_glib);
GUTIL_DEFINE_LOG_FN(gutil_log_syslog);
+GUTIL_DEFINE_LOG_FN2(gutil_log_stdout2); /* Since 1.0.43 */
+GUTIL_DEFINE_LOG_FN2(gutil_log_stderr2); /* Since 1.0.43 */
+GUTIL_DEFINE_LOG_FN2(gutil_log_glib2); /* Since 1.0.43 */
+GUTIL_DEFINE_LOG_FN2(gutil_log_syslog2); /* Since 1.0.43 */
/* Log configuration */
GLOG_MODULE_DECL(gutil_log_default)
-typedef GUTIL_DEFINE_LOG_FN((*GLogProc));
-typedef GUTIL_DEFINE_LOG_FN2((*GLogProc2));
extern GLogProc gutil_log_func;
extern GLogProc2 gutil_log_func2;
extern gboolean gutil_log_timestamp; /* Only affects stdout and stderr */
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/src/gutil_log.c
^
|
@@ -58,7 +58,7 @@
GLogModule gutil_log_default = {
NULL, /* name */
NULL, /* parent */
- NULL, /* reserved */
+ NULL, /* log_proc */
GLOG_LEVEL_MAX, /* max_level */
GLOG_LEVEL_DEFAULT, /* level */
0, /* flags */
@@ -218,6 +218,26 @@
gutil_log_stdio(stderr, name, level, format, va);
}
+void
+gutil_log_stdout2(
+ const GLogModule* module,
+ int level,
+ const char* format,
+ va_list va) /* Since 1.0.43 */
+{
+ gutil_log_stdout(module ? module->name : NULL, level, format, va);
+}
+
+void
+gutil_log_stderr2(
+ const GLogModule* module,
+ int level,
+ const char* format,
+ va_list va) /* Since 1.0.43 */
+{
+ gutil_log_stderr(module ? module->name : NULL, level, format, va);
+}
+
/* Formards output to syslog */
#if GLOG_SYSLOG
#include <syslog.h>
@@ -274,6 +294,16 @@
vsyslog(priority, format, va);
}
}
+
+void
+gutil_log_syslog2(
+ const GLogModule* module,
+ int level,
+ const char* format,
+ va_list va) /* Since 1.0.43 */
+{
+ gutil_log_syslog(module ? module->name : NULL, level, format, va);
+}
#endif /* GLOG_SYSLOG */
/* Forwards output to g_logv */
@@ -296,6 +326,16 @@
}
g_logv(name, flags, format, va);
}
+
+void
+gutil_log_glib2(
+ const GLogModule* module,
+ int level,
+ const char* format,
+ va_list va) /* Since 1.0.43 */
+{
+ gutil_log_glib(module ? module->name : NULL, level, format, va);
+}
#endif /* GLOG_GLIB */
/**
@@ -336,11 +376,11 @@
check->level : gutil_log_default.level;
if ((level > GLOG_LEVEL_NONE && level <= max_level) ||
(level == GLOG_LEVEL_ALWAYS)) {
- GLogProc2 log = gutil_log_func2;
- if (G_LIKELY(log)) {
- if (!module) module = &gutil_log_default;
- log(module, level, format, va);
- }
+ GLogProc2 log;
+ /* Caller makes sure that at least gutil_log_func2 is there */
+ if (!module) module = &gutil_log_default;
+ log = module->log_proc ? module->log_proc : gutil_log_func2;
+ log(module, level, format, va);
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/test/test_log/Makefile
^
|
@@ -1,5 +1,6 @@
# -*- Mode: makefile-gmake -*-
+CFLAGS += -DGLOG_LEVEL_MAX=GLOG_LEVEL_VERBOSE
EXE = test_log
include ../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libglibutil-1.0.43.tar.bz2/test/test_log/test_log.c
^
|
@@ -135,6 +135,16 @@
static
void
+test_log_drop(
+ const GLogModule* module,
+ int level,
+ const char* format,
+ va_list va)
+{
+}
+
+static
+void
test_log_file(
void)
{
@@ -145,6 +155,7 @@
FILE* out = fopencookie(buf, "w", funcs);
FILE* default_stdout = stdout;
const int level = gutil_log_default.level;
+ GLogProc2 log_proc;
g_assert(out);
g_assert(gutil_log_set_type(GLOG_TYPE_STDOUT, NULL));
@@ -200,6 +211,13 @@
g_assert(!g_strcmp0(buf->str, "Test\n"));
g_string_set_size(buf, 0);
+ /* Forward output to test_log_drop */
+ log_proc = gutil_log_default.log_proc;
+ gutil_log_default.log_proc = test_log_drop;
+ gutil_log(&gutil_log_default, GLOG_LEVEL_ALWAYS, "Test");
+ g_assert(!buf->len); /* Dropped by test_log_drop */
+ gutil_log_default.log_proc = log_proc;
+
fclose(out);
gutil_log_default.level = level;
g_string_free(buf, TRUE);
|