logging: make libi3 use verboselog()/errorlog(), provide it in each caller
While this is a bit ugly, it makes the log messages end up where they are supposed to: in the shmlog/stdout in case of i3 and on stdout in case of utilities such as i3-input
This commit is contained in:
parent
6c9bf84d4e
commit
2896ae8057
|
@ -84,6 +84,26 @@ Display *dpy;
|
||||||
char *rewrite_binding(const char *bindingline);
|
char *rewrite_binding(const char *bindingline);
|
||||||
static void finish();
|
static void finish();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Having verboselog() and errorlog() is necessary when using libi3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void verboselog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stdout, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void errorlog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function resolves ~ in pathnames.
|
* This function resolves ~ in pathnames.
|
||||||
* It may resolve wildcards in the first part of the path, but if no match
|
* It may resolve wildcards in the first part of the path, but if no match
|
||||||
|
|
|
@ -56,6 +56,26 @@ xcb_window_t root;
|
||||||
xcb_connection_t *conn;
|
xcb_connection_t *conn;
|
||||||
xcb_screen_t *root_screen;
|
xcb_screen_t *root_screen;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Having verboselog() and errorlog() is necessary when using libi3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void verboselog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stdout, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void errorlog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Concats the glyphs (either UCS-2 or UTF-8) to a single string, suitable for
|
* Concats the glyphs (either UCS-2 or UTF-8) to a single string, suitable for
|
||||||
* rendering it (UCS-2) or sending it to i3 (UTF-8).
|
* rendering it (UCS-2) or sending it to i3 (UTF-8).
|
||||||
|
|
|
@ -56,6 +56,26 @@ xcb_window_t root;
|
||||||
xcb_connection_t *conn;
|
xcb_connection_t *conn;
|
||||||
xcb_screen_t *root_screen;
|
xcb_screen_t *root_screen;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Having verboselog() and errorlog() is necessary when using libi3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void verboselog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stdout, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void errorlog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts the given application by passing it through a shell. We use double fork
|
* Starts the given application by passing it through a shell. We use double fork
|
||||||
* to avoid zombie processes. As the started application’s parent exits (immediately),
|
* to avoid zombie processes. As the started application’s parent exits (immediately),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* vim:ts=4:sw=4:expandtab
|
* vim:ts=4:sw=4:expandtab
|
||||||
*
|
*
|
||||||
* i3bar - an xcb-based status- and ws-bar for i3
|
* i3bar - an xcb-based status- and ws-bar for i3
|
||||||
* © 2010-2011 Axel Wagner and contributors (see also: LICENSE)
|
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -17,6 +17,26 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Having verboselog() and errorlog() is necessary when using libi3.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void verboselog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stdout, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void errorlog(char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Glob path, i.e. expand ~
|
* Glob path, i.e. expand ~
|
||||||
*
|
*
|
||||||
|
|
|
@ -69,10 +69,12 @@ struct Font {
|
||||||
/* Since this file also gets included by utilities which don’t use the i3 log
|
/* Since this file also gets included by utilities which don’t use the i3 log
|
||||||
* infrastructure, we define a fallback. */
|
* infrastructure, we define a fallback. */
|
||||||
#if !defined(LOG)
|
#if !defined(LOG)
|
||||||
#define LOG(fmt, ...) fprintf(stdout, "[libi3] " __FILE__ " " fmt, ##__VA_ARGS__)
|
void verboselog(char *fmt, ...);
|
||||||
|
#define LOG(fmt, ...) verboselog("[libi3] " __FILE__ " " fmt, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
#if !defined(ELOG)
|
#if !defined(ELOG)
|
||||||
#define ELOG(fmt, ...) fprintf(stderr, "[libi3] ERROR: " fmt, ##__VA_ARGS__)
|
void errorlog(char *fmt, ...);
|
||||||
|
#define ELOG(fmt, ...) errorlog("[libi3] ERROR: " fmt, ##__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,13 +38,12 @@ static double pango_font_blue;
|
||||||
static bool load_pango_font(i3Font *font, const char *desc) {
|
static bool load_pango_font(i3Font *font, const char *desc) {
|
||||||
/* Load the font description */
|
/* Load the font description */
|
||||||
font->specific.pango_desc = pango_font_description_from_string(desc);
|
font->specific.pango_desc = pango_font_description_from_string(desc);
|
||||||
if (!font->specific.pango_desc)
|
if (!font->specific.pango_desc) {
|
||||||
{
|
|
||||||
ELOG("Could not open font %s with Pango, fallback to X font.\n", desc);
|
ELOG("Could not open font %s with Pango, fallback to X font.\n", desc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Using Pango font %s, size %d",
|
LOG("Using Pango font %s, size %d\n",
|
||||||
pango_font_description_get_family(font->specific.pango_desc),
|
pango_font_description_get_family(font->specific.pango_desc),
|
||||||
pango_font_description_get_size(font->specific.pango_desc)
|
pango_font_description_get_size(font->specific.pango_desc)
|
||||||
);
|
);
|
||||||
|
@ -186,7 +185,7 @@ i3Font load_font(const char *pattern, const bool fallback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG("Using X font %s", pattern);
|
LOG("Using X font %s\n", pattern);
|
||||||
|
|
||||||
/* Get information (height/name) for this font */
|
/* Get information (height/name) for this font */
|
||||||
if (!(font.specific.xcb.info = xcb_query_font_reply(conn, info_cookie, NULL)))
|
if (!(font.specific.xcb.info = xcb_query_font_reply(conn, info_cookie, NULL)))
|
||||||
|
|
Loading…
Reference in New Issue