Commit b7691afb authored by o9000's avatar o9000

Print logging output consistently to stderr

parent 61c61c88
......@@ -68,7 +68,7 @@ static struct uevent_notify psy_change = {UEVENT_CHANGE, "power_supply", NULL, u
static void uevent_battery_plug()
{
printf("reinitialize batteries after HW change\n");
fprintf(stderr, "reinitialize batteries after HW change\n");
reinit_battery();
}
static struct uevent_notify psy_plug = {UEVENT_ADD | UEVENT_REMOVE, "power_supply", NULL, uevent_battery_plug};
......
......@@ -18,16 +18,17 @@
void print_usage()
{
printf("Usage: tint2 [OPTION...]\n"
"\n"
"Options:\n"
" -c path_to_config_file Loads the configuration file from a\n"
" custom location.\n"
" -v, --version Prints version information and exits.\n"
" -h, --help Display this help and exits.\n"
"\n"
"For more information, run `man tint2` or visit the project page\n"
"<https://gitlab.com/o9000/tint2>.\n");
fprintf(stdout,
"Usage: tint2 [OPTION...]\n"
"\n"
"Options:\n"
" -c path_to_config_file Loads the configuration file from a\n"
" custom location.\n"
" -v, --version Prints version information and exits.\n"
" -h, --help Display this help and exits.\n"
"\n"
"For more information, run `man tint2` or visit the project page\n"
"<https://gitlab.com/o9000/tint2>.\n");
}
void handle_cli_arguments(int argc, char **argv)
......@@ -39,7 +40,7 @@ void handle_cli_arguments(int argc, char **argv)
print_usage();
exit(0);
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
printf("tint2 version %s\n", VERSION_STRING);
fprintf(stdout, "tint2 version %s\n", VERSION_STRING);
exit(0);
} else if (strcmp(argv[i], "-c") == 0) {
if (i + 1 < argc) {
......
......@@ -126,14 +126,14 @@ gboolean read_desktop_file_full_path(const char *path, DesktopEntry *entry)
int lang_index_default = 1;
#define LANG_DBG 0
if (LANG_DBG)
printf("Languages:");
fprintf(stderr, "Languages:");
for (int i = 0; languages[i]; i++) {
lang_index_default = i + 1;
if (LANG_DBG)
printf(" %s", languages[i]);
fprintf(stderr, " %s", languages[i]);
}
if (LANG_DBG)
printf("\n");
fprintf(stderr, "\n");
// we currently do not know about any Name key at all, so use an invalid index
int lang_index_name = lang_index_default + 1;
int lang_index_generic_name = lang_index_default + 1;
......@@ -281,7 +281,7 @@ void test_read_desktop_file()
fprintf(stdout, "\033[1;33m");
DesktopEntry entry;
read_desktop_file("/usr/share/applications/firefox.desktop", &entry);
printf("Name:%s GenericName:%s Icon:%s Exec:%s\n", entry.name, entry.generic_name, entry.icon, entry.exec);
fprintf(stderr, "Name:%s GenericName:%s Icon:%s Exec:%s\n", entry.name, entry.generic_name, entry.icon, entry.exec);
fprintf(stdout, "\033[0m");
}
......
......@@ -330,19 +330,19 @@ void test_launcher_read_theme_file()
fprintf(stdout, "\033[1;33m");
IconTheme *theme = load_theme("oxygen");
if (!theme) {
printf("Could not load theme\n");
fprintf(stderr, "Could not load theme\n");
return;
}
printf("Loaded theme: %s\n", theme->name);
fprintf(stderr, "Loaded theme: %s\n", theme->name);
GSList *item = theme->list_inherits;
while (item != NULL) {
printf("Inherits:%s\n", (char *)item->data);
fprintf(stderr, "Inherits:%s\n", (char *)item->data);
item = g_slist_next(item);
}
item = theme->list_directories;
while (item != NULL) {
IconThemeDir *dir = item->data;
printf("Dir:%s Size=%d MinSize=%d MaxSize=%d Threshold=%d Type=%s\n",
fprintf(stderr, "Dir:%s Size=%d MinSize=%d MaxSize=%d Threshold=%d Type=%s\n",
dir->name,
dir->size,
dir->min_size,
......@@ -623,10 +623,10 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
// filename = directory/$(themename)/subdirectory/iconname.extension
sprintf(file_name, "%s/%s/%s/%s%s", base_name, theme_name, dir_name, icon_name, extension);
if (debug_icons)
printf("Checking %s\n", file_name);
fprintf(stderr, "Checking %s\n", file_name);
if (g_file_test(file_name, G_FILE_TEST_EXISTS)) {
if (debug_icons)
printf("Found potential match: %s\n", file_name);
fprintf(stderr, "Found potential match: %s\n", file_name);
// Closest match
if (directory_size_distance((IconThemeDir *)dir->data, size) < minimal_size &&
(!best_file_theme ? 1 : theme == best_file_theme)) {
......@@ -638,7 +638,7 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
minimal_size = directory_size_distance((IconThemeDir *)dir->data, size);
best_file_theme = theme;
if (debug_icons)
printf("best_file_name = %s; minimal_size = %d\n", best_file_name, minimal_size);
fprintf(stderr, "best_file_name = %s; minimal_size = %d\n", best_file_name, minimal_size);
}
// Next larger match
if (((IconThemeDir *)dir->data)->size >= size &&
......@@ -652,7 +652,7 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
next_larger_size = ((IconThemeDir *)dir->data)->size;
next_larger_theme = theme;
if (debug_icons)
printf("next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size);
fprintf(stderr, "next_larger = %s; next_larger_size = %d\n", next_larger, next_larger_size);
}
}
}
......@@ -683,10 +683,10 @@ char *get_icon_path_helper(GSList *themes, const char *icon_name, int size)
// filename = directory/iconname.extension
sprintf(file_name, "%s/%s%s", base_name, icon_name, extension);
if (debug_icons)
printf("Checking %s\n", file_name);
fprintf(stderr, "Checking %s\n", file_name);
if (g_file_test(file_name, G_FILE_TEST_EXISTS)) {
if (debug_icons)
printf("Found %s\n", file_name);
fprintf(stderr, "Found %s\n", file_name);
g_slist_free(extensions);
return file_name;
} else {
......
......@@ -297,7 +297,7 @@ gboolean resize_launcher(void *obj)
launcherIcon->y = posy;
launcherIcon->x = posx;
launcher_icon_on_change_layout(launcherIcon);
// printf("launcher %d : %d,%d\n", i, posx, posy);
// fprintf(stderr, "launcher %d : %d,%d\n", i, posx, posy);
if (panel_horizontal) {
if (i % icons_per_column) {
posy += launcher->icon_size + launcher->area.paddingx;
......
......@@ -420,7 +420,7 @@ XSettingsClient *xsettings_client_new(Display *display,
check_manager_window(client);
if (client->manager_window == None) {
printf("No XSETTINGS manager, tint2 uses config option 'launcher_icon_theme'.\n");
fprintf(stderr, "No XSETTINGS manager, tint2 uses config option 'launcher_icon_theme'.\n");
free(client);
return NULL;
} else {
......
......@@ -256,7 +256,7 @@ void handle_event_property_notify(XEvent *e)
}
return;
}
// printf("atom root_win = %s, %s\n", XGetAtomName(server.display, at), task->title);
// fprintf(stderr, "atom root_win = %s, %s\n", XGetAtomName(server.display, at), task->title);
// Window title changed
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
......@@ -305,7 +305,7 @@ void handle_event_property_notify(XEvent *e)
// Window desktop changed
else if (at == server.atom._NET_WM_DESKTOP) {
int desktop = get_window_desktop(win);
// printf(" Window desktop changed %d, %d\n", task->desktop, desktop);
// fprintf(stderr, " Window desktop changed %d, %d\n", task->desktop, desktop);
// bug in windowmaker : send unecessary 'desktop changed' when focus changed
if (desktop != task->desktop) {
task_update_desktop(task);
......
......@@ -209,7 +209,7 @@ void init_panel()
}
fprintf(stderr,
"tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n",
"tint2 : nb monitors %d, nb monitors used %d, nb desktops %d\n",
server.num_monitors,
num_panels,
server.num_desktops);
......@@ -289,7 +289,7 @@ void init_panel()
XGCValues gcv;
server.gc = XCreateGC(server.display, p->main_win, 0, &gcv);
}
// printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
// fprintf(stderr, "panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
set_panel_properties(p);
set_panel_background(p);
if (!snapshot_path) {
......@@ -322,7 +322,7 @@ void panel_compute_size(Panel *panel)
if (panel->fractional_height)
panel->area.height = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.height / 100;
if (panel->area.bg->border.radius > panel->area.height / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
fprintf(stderr, "panel_background_id rounded is too big... please fix your tint2rc\n");
g_array_append_val(backgrounds, *panel->area.bg);
panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
panel->area.bg->border.radius = panel->area.height / 2;
......@@ -348,7 +348,7 @@ void panel_compute_size(Panel *panel)
panel->area.width = old_panel_height;
if (panel->area.bg->border.radius > panel->area.width / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
fprintf(stderr, "panel_background_id rounded is too big... please fix your tint2rc\n");
g_array_append_val(backgrounds, *panel->area.bg);
panel->area.bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
panel->area.bg->border.radius = panel->area.width / 2;
......@@ -401,7 +401,7 @@ void panel_compute_position(Panel *panel)
panel->hidden_width = panel->area.width - diff;
panel->hidden_height = panel->area.height;
}
// printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width,
// fprintf(stderr, "panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width,
// panel->area.height);
}
......@@ -416,7 +416,7 @@ gboolean resize_panel(void *obj)
Panel *panel = (Panel *)obj;
relayout_with_constraint(&panel->area, 0);
// printf("resize_panel\n");
// fprintf(stderr, "resize_panel\n");
if (taskbar_mode != MULTI_DESKTOP && taskbar_enabled) {
// propagate width/height on hidden taskbar
int width = panel->taskbar[server.desktop].area.width;
......
......@@ -425,14 +425,14 @@ void get_monitors()
if (res && res->ncrtc >= num_monitors) {
// use xrandr to identify monitors (does not work with proprietery nvidia drivers)
printf("xRandr: Found crtc's: %d\n", res->ncrtc);
fprintf(stderr, "xRandr: Found crtc's: %d\n", res->ncrtc);
server.monitors = calloc(res->ncrtc, sizeof(Monitor));
num_monitors = 0;
for (int i = 0; i < res->ncrtc; ++i) {
XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]);
// Ignore empty crtc
if (!crtc_info->width || !crtc_info->height) {
printf("xRandr: crtc %d seems disabled\n", i);
fprintf(stderr, "xRandr: crtc %d seems disabled\n", i);
XRRFreeCrtcInfo(crtc_info);
continue;
}
......@@ -445,7 +445,7 @@ void get_monitors()
server.monitors[i_monitor].names = calloc((crtc_info->noutput + 1), sizeof(gchar *));
for (int j = 0; j < crtc_info->noutput; ++j) {
XRROutputInfo *output_info = XRRGetOutputInfo(server.display, res, crtc_info->outputs[j]);
printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i);
fprintf(stderr, "xRandr: Linking output %s with crtc %d\n", output_info->name, i);
server.monitors[i_monitor].names[j] = g_strdup(output_info->name);
XRRFreeOutputInfo(output_info);
server.monitors[i_monitor].primary = crtc_info->outputs[j] == primary_output;
......@@ -702,14 +702,14 @@ void server_init_visual()
server.real_transparency = TRUE;
server.depth = 32;
printf("real transparency on... depth: %d\n", server.depth);
fprintf(stderr, "real transparency on... depth: %d\n", server.depth);
server.colormap = XCreateColormap(server.display, server.root_win, visual, AllocNone);
server.visual = visual;
} else {
// no composite manager or snapshot mode => fake transparency
server.real_transparency = FALSE;
server.depth = DefaultDepth(server.display, server.screen);
printf("real transparency off.... depth: %d\n", server.depth);
fprintf(stderr, "real transparency off.... depth: %d\n", server.depth);
server.colormap = DefaultColormap(server.display, server.screen);
server.visual = DefaultVisual(server.display, server.screen);
}
......@@ -732,7 +732,7 @@ void forward_click(XEvent *e)
// and xfce doesn't open at all.
e->xbutton.x = e->xbutton.x_root;
e->xbutton.y = e->xbutton.y_root;
// printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
// fprintf(stderr, "**** %d, %d\n", e->xbutton.x, e->xbutton.y);
// XSetInputFocus(server.display, e->xbutton.window, RevertToParent, e->xbutton.time);
XSendEvent(server.display, e->xbutton.window, False, ButtonPressMask, e);
}
......
......@@ -198,7 +198,7 @@ void remove_task(Task *task)
// free title and icon just for the first task
// even with task_on_all_desktop and with task_on_all_panel
// printf("remove_task %s %d\n", task->title, task->desktop);
// fprintf(stderr, "remove_task %s %d\n", task->title, task->desktop);
if (task->title)
free(task->title);
task_remove_icon(task);
......@@ -591,7 +591,7 @@ void reset_active_task()
}
Window w1 = get_active_window();
// printf("Change active task %ld\n", w1);
// fprintf(stderr, "Change active task %ld\n", w1);
if (w1) {
if (!get_task_buttons(w1)) {
......
......@@ -267,7 +267,7 @@ void init_taskbar_panel(void *p)
if (!panel->g_task.background[j])
panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0);
if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) {
printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
fprintf(stderr, "task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
g_array_append_val(backgrounds, *panel->g_task.background[j]);
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1);
......@@ -432,7 +432,7 @@ gboolean resize_taskbar(void *obj)
Taskbar *taskbar = (Taskbar *)obj;
Panel *panel = (Panel *)taskbar->area.panel;
// printf("resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy);
// fprintf(stderr, "resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy);
if (panel_horizontal) {
relayout_with_constraint(&taskbar->area, panel->g_task.maximum_width);
......
......@@ -1839,7 +1839,7 @@ void load_desktop_file(const char *file, gboolean selected)
if (pixbuf)
g_object_unref(pixbuf);
} else {
printf("Could not load %s\n", file);
fprintf(stderr, "Could not load %s\n", file);
GdkPixbuf *pixbuf = load_icon(DEFAULT_ICON);
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
......@@ -1897,7 +1897,7 @@ void load_desktop_entry(const char *file, GList **entries)
DesktopEntry *entry = calloc(1, sizeof(DesktopEntry));
if (!read_desktop_file(file, entry))
printf("Could not load %s\n", file);
fprintf(stderr, "Could not load %s\n", file);
if (entry->hidden_from_menus) {
free(entry);
return;
......
......@@ -981,7 +981,7 @@ unsigned short checksum_txt(FILE *f)
void config_save_file(const char *path)
{
printf("config_save_file : %s\n", path);
fprintf(stderr, "config_save_file : %s\n", path);
FILE *fp;
if ((fp = fopen(path, "w+t")) == NULL)
......
......@@ -223,7 +223,7 @@ void copy_file(const char *path_src, const char *path_dest)
while ((nb = fread(buffer, 1, sizeof(buffer), file_src)) > 0) {
if (nb != fwrite(buffer, 1, nb, file_dest)) {
printf("Error while copying file %s to %s\n", path_src, path_dest);
fprintf(stderr, "Error while copying file %s to %s\n", path_src, path_dest);
}
}
......@@ -931,7 +931,7 @@ void get_text_size2(const PangoFontDescription *font,
*height_ink = rect_ink.height;
*height = rect.height;
*width = rect.width;
// printf("dimension : %d - %d\n", rect_ink.height, rect.height);
// fprintf(stderr, "dimension : %d - %d\n", rect_ink.height, rect.height);
g_object_unref(layout);
cairo_destroy(c);
......
......@@ -194,7 +194,7 @@ int uevent_init()
return -1;
}
printf("Kernel uevent interface initialized...\n");
fprintf(stderr, "Kernel uevent interface initialized...\n");
return uevent_fd;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment