aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_utilities.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-21 18:28:19 +1000
committerDavid Walter Seikel2014-04-21 18:28:19 +1000
commit26df7205616dbcf80b60c1ed3c04ebea26975fe9 (patch)
tree7bc3851bf7eb3232367cdf8dc6894acf6cb51780 /LuaSL/src/LuaSL_utilities.c
parentGuiLua uses LumbrJack and Runnr from the shared libraries directory at run ti... (diff)
downloadSledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.zip
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.gz
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.bz2
SledjHamr-26df7205616dbcf80b60c1ed3c04ebea26975fe9.tar.xz
Convert LuaSL to use LumbrJack.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_utilities.c84
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" 4void sendBack(gameGlobals *ourGlobals, Ecore_Con_Client *client, const char *SID, const char *message, ...)
5# define DATE_TIME_LEN 21
6
7
8char dateTime[DATE_TIME_LEN];
9
10
11static
12void _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
33void 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
57char *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
80void 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
97void sendForth(gameGlobals *game, const char *SID, const char *message, ...) 21void 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
114float timeDiff(struct timeval *now, struct timeval *then) 38float timeDiff(struct timeval *now, struct timeval *then)