X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Flog.c;h=e75148f127fce4c13c7b6bcc4868f9b7bb2bcb7b;hp=d8358363efa46a6637abed17b88148af97c9716f;hb=c63b2bf21dc1df9a736f0b4c08f6cba828cdab92;hpb=182a15ca19841f241f35e491965a32a51598fc49 diff --git a/lib/log.c b/lib/log.c index d835836..e75148f 100644 --- a/lib/log.c +++ b/lib/log.c @@ -20,19 +20,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __NT__ -#include "stdafx.h" -#include #include +#include +#include +#ifdef WIN32 +//#include "stdafx.h" #include #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #else #include -#include -#include -#include #include #endif @@ -47,6 +45,10 @@ int getScreenLogLevel() { return screenloglevel; } +int getLogLevel() +{ + return maxloglevel; +} void setConsoleLogging(int level) { @@ -70,10 +72,10 @@ void setFileLogging(char*filename, int level, char append) } } /* deprecated */ -void initLog(char* filename, int fileloglevel, char* s00, char* s01, int s02, int screenlevel) +void initLog(char* filename, int filelevel, char* s00, char* s01, int s02, int screenlevel) { - setFileLogging(filename, fileloglevel, 0); - setConsoleLogging(screenloglevel); + setFileLogging(filename, filelevel, 0); + setConsoleLogging(screenlevel); } void exitLog() @@ -92,7 +94,7 @@ static char * logimportance[]= {"Fatal","Error","Warning","Notice","Verbose","De static int loglevels=7; static char * logimportance2[]= {" ","FATAL ","ERROR ","WARNING","NOTICE ","VERBOSE","DEBUG ", "TRACE "}; -static inline void log(const char* logString) +static inline void log_str(const char* logString) { char timebuffer[32]; char* logBuffer; @@ -171,7 +173,7 @@ static inline void log(const char* logString) { if (logFile != NULL) { - fprintf(logFile, "%s\n", logBuffer); + fprintf(logFile, "%s\r\n", logBuffer); fflush(logFile); } } @@ -187,7 +189,7 @@ void msg_str(const char* buf) if(x && (x-z)>maxloglevel) return; } - log(buf); + log_str(buf); } void msg(const char* format, ...) { @@ -203,9 +205,9 @@ void msg(const char* format, ...) return; } - vsprintf(buf, format, arglist); + vsnprintf(buf, sizeof(buf)-1, format, arglist); va_end(arglist); strcat(buf, "\n"); - log(buf); + log_str(buf); }