all new logging: optional file log for linux; choose independent logging levels; optional timestamps for console & file logs; cleanup time functions

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4449 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
ac_stef
2009-05-29 16:30:55 +00:00
parent 4003f387c7
commit 374507babf
11 changed files with 263 additions and 349 deletions
+8 -3
View File
@@ -40,16 +40,21 @@ char *getregszvalue(HKEY root, const char *keystr, const char *query)
}
#endif
const char *filenametime()
const char *timestring(bool local, const char *fmt)
{
static string asciitime;
time_t t = time(NULL);
struct tm * timeinfo;
timeinfo = gmtime (&t);
strftime(asciitime, sizeof(string) - 1, "%Y%m%d_%H.%M.%S", timeinfo);
timeinfo = local ? localtime(&t) : gmtime (&t);
strftime(asciitime, sizeof(string) - 1, fmt ? fmt : "%Y%m%d_%H.%M.%S", timeinfo); // sortable time for filenames
return asciitime;
}
const char *asctime()
{
return timestring(true, "%c");
}
char *path(char *s)
{
for(char *t = s; (t = strpbrk(t, "/\\")); *t++ = PATHDIV);