mirror of
https://github.com/Maschell/libutils.git
synced 2025-01-14 04:49:07 +01:00
Added function to "log" via OSFatal
This commit is contained in:
parent
b1d95f6b83
commit
8e3a2f337a
@ -25,7 +25,7 @@ void log_init_(){
|
||||
memset(&connect_addr, 0, sizeof(struct sockaddr_in));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = 4405;
|
||||
connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
|
||||
connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
|
||||
}
|
||||
|
||||
void log_print_(const char *str){
|
||||
@ -33,11 +33,11 @@ void log_print_(const char *str){
|
||||
if(log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while(log_lock)
|
||||
os_usleep(1000);
|
||||
log_lock = 1;
|
||||
|
||||
|
||||
int len = strlen(str);
|
||||
int ret;
|
||||
while (len > 0) {
|
||||
@ -53,13 +53,23 @@ void log_print_(const char *str){
|
||||
log_lock = 0;
|
||||
}
|
||||
|
||||
void OSFatal_printf(const char *format, ...){
|
||||
char * tmp = NULL;
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vasprintf(&tmp, format, va) >= 0) && tmp){
|
||||
OSFatal(tmp);
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void log_printf_(const char *format, ...)
|
||||
{
|
||||
if(log_socket < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char * tmp = NULL;
|
||||
|
||||
va_list va;
|
||||
|
@ -11,6 +11,14 @@ void log_init_();
|
||||
//void log_deinit_(void);
|
||||
void log_print_(const char *str);
|
||||
void log_printf_(const char *format, ...);
|
||||
void OSFatal_printf(const char *format, ...);
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef __LOGGING__
|
||||
|
||||
@ -19,13 +27,11 @@ void log_printf_(const char *format, ...);
|
||||
#define log_print(str) log_print_(str)
|
||||
#define log_printf(FMT, ARGS...) log_printf_(FMT, ## ARGS);
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||
log_printf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#define log_init()
|
||||
|
Loading…
x
Reference in New Issue
Block a user