project_files/frontlib/logging.c
changeset 7162 fe76d24a25d7
parent 7160 c42949cfdd92
child 7177 bf6cf4dd847a
equal deleted inserted replaced
7160:c42949cfdd92 7162:fe76d24a25d7
     1 #include "logging.h"
     1 #include "logging.h"
     2 
     2 
     3 #include <time.h>
     3 #include <time.h>
     4 #include <stdio.h>
     4 #include <stdio.h>
     5 #include <stdarg.h>
     5 #include <stdarg.h>
       
     6 #include <stdlib.h>
     6 
     7 
     7 char* flib_format_ip(uint32_t numip) {
     8 char* flib_format_ip(uint32_t numip) {
     8 	static char ip[16];
     9 	static char ip[16];
     9 	snprintf(ip, 16, "%u.%u.%u.%u", numip>>24, (numip>>16)&0xff, (numip>>8)&0xff, numip&0xff);
    10 	snprintf(ip, 16, "%u.%u.%u.%u", numip>>24, (numip>>16)&0xff, (numip>>8)&0xff, numip&0xff);
    10 	return ip;
    11 	return ip;
    25 static void flib_vflog(FILE *file, const char *prefix, const char *fmt, va_list args) {
    26 static void flib_vflog(FILE *file, const char *prefix, const char *fmt, va_list args) {
    26 	log_time(file);
    27 	log_time(file);
    27 	fprintf(file, " [%s]", prefix);
    28 	fprintf(file, " [%s]", prefix);
    28 	vfprintf(file, fmt, args);
    29 	vfprintf(file, fmt, args);
    29 	fprintf(file, "\n");
    30 	fprintf(file, "\n");
       
    31 	fflush(file);
    30 }
    32 }
    31 
    33 
    32 void flib_log_e(const char *fmt, ...) {
    34 void flib_log_e(const char *fmt, ...) {
    33 	va_list argp;
    35 	va_list argp;
    34 	va_start(argp, fmt);
    36 	va_start(argp, fmt);