diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_utilities.c | 84 |
1 files changed, 4 insertions, 80 deletions
diff --git a/LuaSL/src/LuaSL_utilities.c b/LuaSL/src/LuaSL_utilities.c index e25b46c..40263df 100644 --- a/LuaSL/src/LuaSL_utilities.c +++ b/LuaSL/src/LuaSL_utilities.c | |||
@@ -1,83 +1,7 @@ | |||
1 | #include "LuaSL.h" | 1 | #include "LuaSL.h" |
2 | 2 | ||
3 | 3 | ||
4 | // "01:03:52 01-01-1973\n\0" | 4 | void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...) |
5 | # define DATE_TIME_LEN 21 | ||
6 | |||
7 | |||
8 | char dateTime[DATE_TIME_LEN]; | ||
9 | |||
10 | |||
11 | static | ||
12 | void _ggg_log_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args) | ||
13 | { | ||
14 | FILE *f = data; | ||
15 | char dt[DATE_TIME_LEN + 1]; | ||
16 | char fileTab[256], funcTab[256]; | ||
17 | |||
18 | getDateTime(NULL, dt, NULL); | ||
19 | dt[19] = '\0'; | ||
20 | if (12 > strlen(file)) | ||
21 | snprintf(fileTab, sizeof(fileTab), "%s\t\t", file); | ||
22 | else | ||
23 | snprintf(fileTab, sizeof(fileTab), "%s\t", file); | ||
24 | snprintf(funcTab, sizeof(funcTab), "\t%s", fnc); | ||
25 | fprintf(f, "%s ", dt); | ||
26 | if (f == stderr) | ||
27 | eina_log_print_cb_stderr(d, level, fileTab, funcTab, line, fmt, data, args); | ||
28 | else if (f == stdout) | ||
29 | eina_log_print_cb_stdout(d, level, fileTab, funcTab, line, fmt, data, args); | ||
30 | fflush(f); | ||
31 | } | ||
32 | |||
33 | void loggingStartup(gameGlobals *game) | ||
34 | { | ||
35 | game->logDom = eina_log_domain_register("LuaSL", NULL); | ||
36 | if (game->logDom < 0) | ||
37 | { | ||
38 | EINA_LOG_CRIT("could not register log domain 'LuaSL'"); | ||
39 | } | ||
40 | // TODO - should unregister this later. | ||
41 | eina_log_level_set(EINA_LOG_LEVEL_DBG); | ||
42 | eina_log_domain_level_set("LuaSL", EINA_LOG_LEVEL_DBG); | ||
43 | eina_log_print_cb_set(_ggg_log_print_cb, stderr); | ||
44 | |||
45 | // Shut up the excess debugging shit from EFL. | ||
46 | eina_log_domain_level_set("eo", EINA_LOG_LEVEL_WARN); | ||
47 | eina_log_domain_level_set("eldbus", EINA_LOG_LEVEL_WARN); | ||
48 | eina_log_domain_level_set("eet", EINA_LOG_LEVEL_WARN); | ||
49 | eina_log_domain_level_set("ecore", EINA_LOG_LEVEL_WARN); | ||
50 | eina_log_domain_level_set("ecore_audio", EINA_LOG_LEVEL_WARN); | ||
51 | eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_WARN); | ||
52 | eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); | ||
53 | eina_log_domain_level_set("ecore_input_evas", EINA_LOG_LEVEL_WARN); | ||
54 | eina_log_domain_level_set("ecore_system_upower", EINA_LOG_LEVEL_WARN); | ||
55 | } | ||
56 | |||
57 | char *getDateTime(struct tm **nowOut, char *dateOut, time_t *timeOut) | ||
58 | { | ||
59 | struct tm *newTime; | ||
60 | time_t szClock; | ||
61 | char *date = dateTime; | ||
62 | |||
63 | // Get time in seconds | ||
64 | time(&szClock); | ||
65 | // Convert time to struct tm form | ||
66 | newTime = localtime(&szClock); | ||
67 | |||
68 | if (nowOut) | ||
69 | *nowOut = newTime; | ||
70 | if (dateOut) | ||
71 | date = dateOut; | ||
72 | if (timeOut) | ||
73 | *timeOut = szClock; | ||
74 | |||
75 | // format | ||
76 | strftime(date, DATE_TIME_LEN, "%d/%m/%Y %H:%M:%S\r", newTime); | ||
77 | return (dateTime); | ||
78 | } | ||
79 | |||
80 | void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, const char *message, ...) | ||
81 | { | 5 | { |
82 | va_list args; | 6 | va_list args; |
83 | char buf[PATH_MAX]; | 7 | char buf[PATH_MAX]; |
@@ -94,7 +18,7 @@ void sendBack(gameGlobals *game, Ecore_Con_Client *client, const char *SID, cons | |||
94 | ecore_con_client_flush(client); | 18 | ecore_con_client_flush(client); |
95 | } | 19 | } |
96 | 20 | ||
97 | void sendForth(gameGlobals *game, const char *SID, const char *message, ...) | 21 | void sendForth(gameGlobals *ourGlobals, const char *SID, const char *message, ...) |
98 | { | 22 | { |
99 | va_list args; | 23 | va_list args; |
100 | char buf[PATH_MAX]; | 24 | char buf[PATH_MAX]; |
@@ -107,8 +31,8 @@ void sendForth(gameGlobals *game, const char *SID, const char *message, ...) | |||
107 | va_end(args); | 31 | va_end(args); |
108 | buf[length++] = '\n'; | 32 | buf[length++] = '\n'; |
109 | buf[length++] = '\0'; | 33 | buf[length++] = '\0'; |
110 | ecore_con_server_send(game->server, buf, strlen(buf)); | 34 | ecore_con_server_send(ourGlobals->server, buf, strlen(buf)); |
111 | ecore_con_server_flush(game->server); | 35 | ecore_con_server_flush(ourGlobals->server); |
112 | } | 36 | } |
113 | 37 | ||
114 | float timeDiff(struct timeval *now, struct timeval *then) | 38 | float timeDiff(struct timeval *now, struct timeval *then) |