};
#ifdef _WIN32
+
+static Eina_Bool _eina_log_win32_is_console = EINA_FALSE;
/* TODO: query win32_def_attr on eina_log_init() */
static int win32_def_attr = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#ifdef _WIN32
static inline void
-eina_log_print_level_name_color_get(int level,
- const char **p_name,
- int *p_color)
+eina_log_print_level_name_color_get_win32_console(int level,
+ const char **p_name,
+ int *p_color)
{
static char buf[4];
/* NOTE: if you change this, also change:
*p_color = eina_log_win32_color_get(eina_log_level_color_get(level));
}
-#else
+#endif
static inline void
-eina_log_print_level_name_color_get(int level,
- const char **p_name,
- const char **p_color)
+eina_log_print_level_name_color_get_posix(int level,
+ const char **p_name,
+ const char **p_color)
{
static char buf[4];
/* NOTE: if you change this, also change:
*p_color = eina_log_level_color_get(level);
}
-#endif
+
#define DECLARE_LEVEL_NAME(level) const char *name; \
eina_log_print_level_name_get(level, &name)
#ifdef _WIN32
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; \
- eina_log_print_level_name_color_get(level, &name, &color)
-#else
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; \
- eina_log_print_level_name_color_get(level, &name, &color)
+# define DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level) const char *name; int color; \
+ eina_log_print_level_name_color_get_win32_console(level, &name, &color)
#endif
+#define DECLARE_LEVEL_NAME_COLOR_POSIX(level) const char *name, *color; \
+ eina_log_print_level_name_color_get_posix(level, &name, &color)
/** No threads, No color */
static void
int line)
{
DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s<%u>:%s %s:%d %s() ", name, eina_log_pid_get(),
+ fprintf(fp, "%s<%u>:%s %s:%d %s() ", name, eina_log_pid_get(),
d->domain_str, file, line, fnc);
}
int line EINA_UNUSED)
{
DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s<%u>:%s %s() ", name, eina_log_pid_get(), d->domain_str,
+ fprintf(fp, "%s<%u>:%s %s() ", name, eina_log_pid_get(), d->domain_str,
fnc);
}
int line)
{
DECLARE_LEVEL_NAME(level);
- fprintf(fp, "%s<%u>:%s %s:%d ", name, eina_log_pid_get(), d->domain_str,
+ fprintf(fp, "%s<%u>:%s %s:%d ", name, eina_log_pid_get(), d->domain_str,
file, line);
}
/* No threads, color */
+#ifdef _WIN32
static void
-eina_log_print_prefix_NOthreads_color_file_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line)
+eina_log_print_prefix_NOthreads_color_file_func_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
- DECLARE_LEVEL_NAME_COLOR(level);
-#ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
eina_log_win32_color_get(d->domain_str));
fprintf(fp, "%s", d->name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED |
FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, "%s()", fnc);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " ");
-#else
+}
+#endif
+
+static void
+eina_log_print_prefix_NOthreads_color_file_func_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s %s:%d "
EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
color, name, eina_log_pid_get(), d->domain_str, file, line, fnc);
-#endif
}
static void
-eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp,
- const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file EINA_UNUSED,
- const char *fnc,
- int line EINA_UNUSED)
+eina_log_print_prefix_NOthreads_color_file_func(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line)
{
- DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_NOthreads_color_file_func_win32_console(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line);
+ else
+#endif
+ eina_log_print_prefix_NOthreads_color_file_func_posix(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line);
+}
+
+#ifdef _WIN32
+static void
+eina_log_print_prefix_NOthreads_color_NOfile_func_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *fnc)
+{
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
eina_log_win32_color_get(d->domain_str));
fprintf(fp, "%s", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_INTENSITY | FOREGROUND_RED |
FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, "%s()", fnc);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " ");
-#else
+}
+#endif
+
+static void
+eina_log_print_prefix_NOthreads_color_NOfile_func_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *fnc)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s "
EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
color, name, eina_log_pid_get(), d->domain_str, fnc);
-#endif
}
static void
-eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp,
+eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp,
const Eina_Log_Domain *d,
Eina_Log_Level level,
- const char *file,
- const char *fnc EINA_UNUSED,
- int line)
+ const char *file EINA_UNUSED,
+ const char *fnc,
+ int line EINA_UNUSED)
{
- DECLARE_LEVEL_NAME_COLOR(level);
#ifdef _WIN32
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_NOthreads_color_NOfile_func_win32_console(fp,
+ d,
+ level,
+ fnc);
+ else
+#endif
+ eina_log_print_prefix_NOthreads_color_NOfile_func_posix(fp,
+ d,
+ level,
+ fnc);
+}
+
+#ifdef _WIN32
+static void
+eina_log_print_prefix_NOthreads_color_file_NOfunc_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ int line)
+{
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
color);
fprintf(fp, "%s", name);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
fprintf(fp, " %s:%d ", file, line);
-#else
+}
+#endif
+
+static void
+eina_log_print_prefix_NOthreads_color_file_NOfunc_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ int line)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s %s:%d ",
color, name, eina_log_pid_get(), d->domain_str, file, line);
+}
+
+static void
+eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc EINA_UNUSED,
+ int line)
+{
+#ifdef _WIN32
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_NOthreads_color_file_NOfunc_win32_console(fp,
+ d,
+ level,
+ file,
+ line);
+ else
#endif
+ eina_log_print_prefix_NOthreads_color_file_NOfunc_posix(fp,
+ d,
+ level,
+ file,
+ line);
}
/** threads, No color */
if (IS_OTHER(cur))
{
fprintf(fp, "%s<%u>:%s[T:%lu] %s:%d %s() ",
- name, eina_log_pid_get(), d->domain_str,
+ name, eina_log_pid_get(), d->domain_str,
(unsigned long)cur, file, line, fnc);
return;
}
- fprintf(fp, "%s<%u>:%s %s:%d %s() ",
+ fprintf(fp, "%s<%u>:%s %s:%d %s() ",
name, eina_log_pid_get(), d->domain_str, file, line, fnc);
}
if (IS_OTHER(cur))
{
fprintf(fp, "%s<%u>:%s[T:%lu] %s() ",
- name, eina_log_pid_get(), d->domain_str,
+ name, eina_log_pid_get(), d->domain_str,
(unsigned long)cur, fnc);
return;
}
- fprintf(fp, "%s<%u>:%s %s() ",
+ fprintf(fp, "%s<%u>:%s %s() ",
name, eina_log_pid_get(), d->domain_str, fnc);
}
if (IS_OTHER(cur))
{
fprintf(fp, "%s<%u>:%s[T:%lu] %s:%d ",
- name, eina_log_pid_get(), d->domain_str, (unsigned long)cur,
+ name, eina_log_pid_get(), d->domain_str, (unsigned long)cur,
file, line);
return;
}
-
- fprintf(fp, "%s<%u>:%s %s:%d ",
+
+ fprintf(fp, "%s<%u>:%s %s:%d ",
name, eina_log_pid_get(), d->domain_str, file, line);
}
/* threads, color */
+#ifdef _WIN32
+static void
+eina_log_print_prefix_threads_color_file_func_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
+}
+#endif
+
+static void
+eina_log_print_prefix_threads_color_file_func_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
+ fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
+ EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+ color, name, eina_log_pid_get() ,d->domain_str,
+ (unsigned long)cur, file, line, fnc);
+}
+
static void
eina_log_print_prefix_threads_color_file_func(FILE *fp,
const Eina_Log_Domain *d,
{
Eina_Thread cur;
- DECLARE_LEVEL_NAME_COLOR(level);
cur = SELF();
if (IS_OTHER(cur))
{
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, " ");
-# else
- fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, eina_log_pid_get() ,d->domain_str,
- (unsigned long)cur, file, line, fnc);
-# endif
+#ifdef _WIN32
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_threads_color_file_func_win32_console(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line,
+ cur);
+ else
+#endif
+ eina_log_print_prefix_threads_color_file_func_posix(fp,
+ d,
+ level,
+ file,
+ fnc,
+ line,
+ cur);
return;
}
-# ifdef _WIN32
eina_log_print_prefix_NOthreads_color_file_func(fp,
d,
level,
file,
fnc,
line);
-# else
- fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s %s:%d "
+}
+
+#ifdef _WIN32
+static void
+eina_log_print_prefix_threads_color_NOfile_func_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *fnc,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(
+ STD_OUTPUT_HANDLE),
+ FOREGROUND_INTENSITY | FOREGROUND_RED |
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%s()", fnc);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, " ");
+}
+#endif
+
+static void
+eina_log_print_prefix_threads_color_NOfile_func_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *fnc,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
+ fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, eina_log_pid_get(), d->domain_str, file, line, fnc);
-# endif
+ color, name, eina_log_pid_get(), d->domain_str,
+ (unsigned long)cur, fnc);
}
static void
{
Eina_Thread cur;
- DECLARE_LEVEL_NAME_COLOR(level);
cur = SELF();
if (IS_OTHER(cur))
{
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_INTENSITY | FOREGROUND_RED |
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%s()", fnc);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, " ");
-# else
- fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, eina_log_pid_get(), d->domain_str,
- (unsigned long)cur, fnc);
-# endif
+#ifdef _WIN32
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_threads_color_NOfile_func_win32_console(fp,
+ d,
+ level,
+ fnc,
+ cur);
+ else
+#endif
+ eina_log_print_prefix_threads_color_NOfile_func_posix(fp,
+ d,
+ level,
+ fnc,
+ cur);
return;
}
-# ifdef _WIN32
eina_log_print_prefix_NOthreads_color_NOfile_func(fp,
d,
level,
file,
fnc,
line);
-# else
- fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s "
- EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
- color, name, eina_log_pid_get(), d->domain_str, fnc);
-# endif
+}
+
+#ifdef _WIN32
+static void
+eina_log_print_prefix_threads_color_file_NOfunc_win32_console(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ int line,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_WIN32_CONSOLE(level);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ color);
+ fprintf(fp, "%s", name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, ":");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ eina_log_win32_color_get(d->domain_str));
+ fprintf(fp, "%s[T:", d->name);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "[T:");
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_GREEN | FOREGROUND_BLUE);
+ fprintf(fp, "%lu", (unsigned long)cur);
+ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+ FOREGROUND_RED | FOREGROUND_GREEN |
+ FOREGROUND_BLUE);
+ fprintf(fp, "] %s:%d ", file, line);
+}
+#endif
+
+static void
+eina_log_print_prefix_threads_color_file_NOfunc_posix(FILE *fp,
+ const Eina_Log_Domain *d,
+ Eina_Log_Level level,
+ const char *file,
+ int line,
+ Eina_Thread cur)
+{
+ DECLARE_LEVEL_NAME_COLOR_POSIX(level);
+ fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
+ EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
+ color, name, eina_log_pid_get(), d->domain_str,
+ (unsigned long)cur, file, line);
}
static void
{
Eina_Thread cur;
- DECLARE_LEVEL_NAME_COLOR(level);
cur = SELF();
if (IS_OTHER(cur))
{
-# ifdef _WIN32
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- color);
- fprintf(fp, "%s", name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, ":");
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- eina_log_win32_color_get(d->domain_str));
- fprintf(fp, "%s[T:", d->name);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "[T:");
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- FOREGROUND_GREEN | FOREGROUND_BLUE);
- fprintf(fp, "%lu", (unsigned long)cur);
- SetConsoleTextAttribute(GetStdHandle(
- STD_OUTPUT_HANDLE),
- FOREGROUND_RED | FOREGROUND_GREEN |
- FOREGROUND_BLUE);
- fprintf(fp, "] %s:%d ", file, line);
-# else
- fprintf(fp, "%s%s<%u>" EINA_COLOR_RESET ":%s[T:"
- EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
- color, name, eina_log_pid_get(), d->domain_str,
- (unsigned long)cur, file, line);
-# endif
+#ifdef _WIN32
+ if (_eina_log_win32_is_console)
+ eina_log_print_prefix_threads_color_file_NOfunc_win32_console(fp,
+ d,
+ level,
+ file,
+ line,
+ cur);
+ else
+#endif
+ eina_log_print_prefix_threads_color_file_NOfunc_posix(fp,
+ d,
+ level,
+ file,
+ line,
+ cur);
return;
}
-# ifdef _WIN32
eina_log_print_prefix_NOthreads_color_file_NOfunc(fp,
d,
level,
file,
fnc,
line);
-# else
- fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
- color, name, d->domain_str, file, line);
-# endif
}
static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d,
if (level > d->level)
return;
-#ifdef _WIN32
- {
- char *wfmt;
- char *tmp;
-
- wfmt = strdup(fmt);
- if (!wfmt)
- {
- fprintf(stderr, "ERR: %s: can not allocate memory\n", __FUNCTION__);
- return;
- }
-
- tmp = wfmt;
- while (strchr(tmp, '%'))
- {
- tmp++;
- if (*tmp == 'z')
- *tmp = 'I';
- }
- _print_cb(d, level, file, fnc, line, wfmt, _print_cb_data, args);
- free(wfmt);
- }
-#else
_print_cb(d, level, file, fnc, line, fmt, _print_cb_data, args);
-#endif
if (EINA_UNLIKELY(_abort_on_critical) &&
EINA_UNLIKELY(level <= _abort_level_on_critical))
#ifdef EINA_ENABLE_LOG
const char *level, *tmp;
int color_disable;
+# ifdef _WIN32
+ DWORD mode;
+# endif
assert((sizeof(_names) / sizeof(_names[0])) == EINA_LOG_LEVELS);
_disable_color = EINA_TRUE;
}
}
+#else
+ if (GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode))
+ _eina_log_win32_is_console = EINA_TRUE;
#endif
#ifdef HAVE_SYSTEMD
EAPI void
eina_log_print_cb_journald(const Eina_Log_Domain *d,
- Eina_Log_Level level,
- const char *file,
- const char *fnc,
- int line,
- const char *fmt,
- void *data EINA_UNUSED,
- va_list args)
+ Eina_Log_Level level,
+ const char *file,
+ const char *fnc,
+ int line,
+ const char *fmt,
+ void *data EINA_UNUSED,
+ va_list args)
{
#ifdef HAVE_SYSTEMD
char *file_prefixed = NULL;
{
fputs("ERR: eina_log_print_cb_journald() asprintf failed\n", stderr);
goto finish;
- }
+ }
r = vasprintf(&message, fmt, args);
if (r == -1)
if (EINA_LIKELY(level > _backtrace_level))
#endif
sd_journal_send_with_location(file_prefixed, line_str, fnc,
- "PRIORITY=%i", level,
- "MESSAGE=%s", message,
- "EFL_DOMAIN=%s", d->domain_str,
- "THREAD=%lu", cur,
- NULL);
+ "PRIORITY=%i", level,
+ "MESSAGE=%s", message,
+ "EFL_DOMAIN=%s", d->domain_str,
+ "THREAD=%lu", cur,
+ NULL);
#ifdef EINA_LOG_BACKTRACE
else
{
if (IS_OTHER(cur))
{
fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, (unsigned long)cur,
- file, line, fnc);
+ file, line, fnc);
goto end;
}
}
- fprintf(f, "%s<%u> %s:%d %s() ", d->name, eina_log_pid_get(),
+ fprintf(f, "%s<%u> %s:%d %s() ", d->name, eina_log_pid_get(),
file, line, fnc);
DISPLAY_BACKTRACE(f, level);