143 lines
2.9 KiB
C
143 lines
2.9 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
#include "btk-log.h"
|
|
#include "btk-config.h"
|
|
|
|
void
|
|
btk_log(unsigned int log_id)
|
|
{
|
|
if (btk_log_level < 3)
|
|
return;
|
|
|
|
printf("BTK -> LOG -> ");
|
|
switch (log_id)
|
|
{
|
|
case BTK_LOG_SESSION_CLOSE:
|
|
printf("closed btk session");
|
|
break;
|
|
case BTK_LOG_SESSION_OPEN:
|
|
printf("opened new btk session");
|
|
break;
|
|
case BTK_LOG_GENERIC_EVENT_NOTIFY:
|
|
printf("generic x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_LOOP_IN:
|
|
printf("entered event loop");
|
|
break;
|
|
case BTK_LOG_EVENT_LOOP_OUT:
|
|
printf("exited event loop");
|
|
break;
|
|
case BTK_LOG_WINDOW_MAP:
|
|
printf("mapped window");
|
|
break;
|
|
case BTK_LOG_WINDOW_UNMAP:
|
|
printf("unmapped window");
|
|
break;
|
|
case BTK_LOG_WINDOW_CREATE:
|
|
printf("created new window");
|
|
break;
|
|
case BTK_LOG_WINDOW_DESTROY:
|
|
printf("destroyed window");
|
|
break;
|
|
case BTK_LOG_WINDOW_RENAME:
|
|
printf("renamed window");
|
|
break;
|
|
case BTK_LOG_WINDOW_RESIZE:
|
|
printf("resized window");
|
|
break;
|
|
case BTK_LOG_EVENT_EXPOSE:
|
|
printf("expose x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_BUTTON_PRESS:
|
|
printf("button press x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_BUTTON_RELEASE:
|
|
printf("button release x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_BUTTON_COMBO:
|
|
printf("button combo");
|
|
break;
|
|
case BTK_LOG_EVENT_BUTTON_COMBO_BREAK:
|
|
printf("button combo broken");
|
|
break;
|
|
case BTK_LOG_EVENT_KEY_PRESS:
|
|
printf("key press x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_POINTER_MOTION:
|
|
printf("pointer motion x event received");
|
|
break;
|
|
case BTK_LOG_EVENT_WINDOW_ENTER:
|
|
printf("pointer entered new window");
|
|
break;
|
|
case BTK_LOG_EVENT_WINDOW_LEAVE:
|
|
printf("pointer left window");
|
|
break;
|
|
case BTK_LOG_EVENT_CLIENT_MESSAGE:
|
|
printf("x client message received");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
putchar('\n');
|
|
}
|
|
|
|
void
|
|
btk_log_error(unsigned int error_id)
|
|
{
|
|
if (btk_log_level < 1)
|
|
return;
|
|
|
|
printf("BTK -> \033[1;31mERROR\033[0m -> ");
|
|
switch (error_id)
|
|
{
|
|
case BTK_ERROR_X_CONNECTION:
|
|
printf("failed to connect to X");
|
|
break;
|
|
case BTK_ERROR_X_SCREEN:
|
|
printf("failed to get display");
|
|
break;
|
|
case BTK_ERROR_X_KEYSYMS:
|
|
printf("failed to get keysym table");
|
|
break;
|
|
case BTK_ERROR_X_VISUAL:
|
|
printf("failed to get visual type");
|
|
break;
|
|
default:
|
|
printf("generid error");
|
|
break;
|
|
}
|
|
putchar('\n');
|
|
exit(1);
|
|
}
|
|
|
|
void
|
|
btk_log_warning(unsigned int warning_id)
|
|
{
|
|
if (btk_log_level < 2)
|
|
return;
|
|
|
|
printf("BTK -> \033[1;33mWARNING\033[0m -> ");
|
|
switch (warning_id)
|
|
{
|
|
case BTK_WARNING_WINDOW_GET:
|
|
printf("couldn't match x window id to btk window");
|
|
break;
|
|
case BTK_WARNING_EMPTY_LOOP:
|
|
printf("no windows in the event loop");
|
|
break;
|
|
case BTK_WARNING_DRAW_NO_FIELD:
|
|
printf("attempted to draw a field type without a field");
|
|
break;
|
|
case BTK_WARNING_OUT_OF_BOUND_CELL:
|
|
printf("attempted to draw a non exisiting cell");
|
|
break;
|
|
case BTK_WARNING_WINDOW_DESTROY:
|
|
printf("attempted to destroy NULL window");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
putchar('\n');
|
|
}
|