diff --git a/aqvm/base/file/file.c b/aqvm/base/file/file.c index 8213508..090604c 100644 --- a/aqvm/base/file/file.c +++ b/aqvm/base/file/file.c @@ -10,13 +10,13 @@ #include "aqvm/base/threading/mutex/mutex.h" -int AqvmBaseFile_LockFile(struct AqvmBaseFile_File* file) { - if (file == NULL) { +int AqvmBaseFile_LockFile(struct AqvmBaseFile_File* stream) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } - int result = AqvmBaseThreadingMutex_LockMutex(&file->mutex); + int result = AqvmBaseThreadingMutex_LockMutex(&stream->mutex); if (result != 0) { // TODO return -2; @@ -24,13 +24,13 @@ int AqvmBaseFile_LockFile(struct AqvmBaseFile_File* file) { return 0; } -int AqvmBaseFile_UnlockFile(struct AqvmBaseFile_File* file) { - if (file == NULL) { +int AqvmBaseFile_UnlockFile(struct AqvmBaseFile_File* stream) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } - int result = AqvmBaseThreadingMutex_UnlockMutex(&file->mutex); + int result = AqvmBaseThreadingMutex_UnlockMutex(&stream->mutex); if (result != 0) { // TODO return -2; @@ -38,8 +38,25 @@ int AqvmBaseFile_UnlockFile(struct AqvmBaseFile_File* file) { return 0; } +int AqvmBaseFile_CheckStream(struct AqvmBaseFile_File* stream) { + if (stream == NULL) { + // TODO + return -1; + } + if (stream->file == NULL) { + // TODO + return -2; + } + if (AqvmBaseFile_ferror(stream) != 0) { + // TODO + return -3; + } + + return 0; +} + void AqvmBaseFile_clearerr(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return; } @@ -48,7 +65,7 @@ void AqvmBaseFile_clearerr(struct AqvmBaseFile_File* stream) { } int AqvmBaseFile_fclose(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } @@ -70,7 +87,7 @@ int AqvmBaseFile_fclose(struct AqvmBaseFile_File* stream) { } int AqvmBaseFile_feof(struct AqvmBaseFile_File* stream) { - if (stream == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } @@ -80,7 +97,7 @@ int AqvmBaseFile_feof(struct AqvmBaseFile_File* stream) { } int AqvmBaseFile_ferror(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || ferror(stream->file)) { + if (stream == NULL || stream->file == NULL) { // TODO return -1; } @@ -90,7 +107,7 @@ int AqvmBaseFile_ferror(struct AqvmBaseFile_File* stream) { } int AqvmBaseFile_fflush(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } @@ -116,8 +133,7 @@ int AqvmBaseFile_fflush(struct AqvmBaseFile_File* stream) { } int AqvmBaseFile_fgetpos(struct AqvmBaseFile_File* stream, fpos_t* pos) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0 || - pos == NULL) { + if (AqvmBaseFile_CheckStream(stream) || pos == NULL) { // TODO return -1; } @@ -173,8 +189,7 @@ struct AqvmBaseFile_File* AqvmBaseFile_fopen(const char* filename, size_t AqvmBaseFile_fread(void* ptr, size_t size, size_t nmemb, struct AqvmBaseFile_File* stream) { - if (ptr == NULL || stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (ptr == NULL || AqvmBaseFile_CheckStream(stream)) { // TODO return 0; } @@ -196,8 +211,7 @@ size_t AqvmBaseFile_fread(void* ptr, size_t size, size_t nmemb, struct AqvmBaseFile_File* AqvmBaseFile_freopen( const char* filename, const char* mode, struct AqvmBaseFile_File* stream) { - if (filename == NULL || mode == NULL || stream == NULL || - stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (filename == NULL || mode == NULL || AqvmBaseFile_CheckStream(stream)) { // TODO return NULL; } @@ -229,7 +243,7 @@ struct AqvmBaseFile_File* AqvmBaseFile_freopen( int AqvmBaseFile_fseek(struct AqvmBaseFile_File* stream, long int offset, int whence) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } @@ -255,8 +269,7 @@ int AqvmBaseFile_fseek(struct AqvmBaseFile_File* stream, long int offset, } int AqvmBaseFile_fsetpos(struct AqvmBaseFile_File* stream, const fpos_t* pos) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0 || - pos == NULL) { + if (AqvmBaseFile_CheckStream(stream) || pos == NULL) { // TODO return -1; } @@ -282,7 +295,7 @@ int AqvmBaseFile_fsetpos(struct AqvmBaseFile_File* stream, const fpos_t* pos) { } long int AqvmBaseFile_ftell(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1L; } @@ -309,8 +322,7 @@ long int AqvmBaseFile_ftell(struct AqvmBaseFile_File* stream) { size_t AqvmBaseFile_fwrite(const void* ptr, size_t size, size_t nmemb, struct AqvmBaseFile_File* stream) { - if (ptr == NULL || stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (ptr == NULL || AqvmBaseFile_CheckStream(stream)) { // TODO return 0; } @@ -359,7 +371,7 @@ int AqvmBaseFile_rename(const char* old_filename, const char* new_filename) { } void AqvmBaseFile_rewind(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return; } @@ -377,7 +389,7 @@ void AqvmBaseFile_rewind(struct AqvmBaseFile_File* stream) { } void AqvmBaseFile_setbuf(struct AqvmBaseFile_File* stream, char* buffer) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return; } @@ -396,7 +408,7 @@ void AqvmBaseFile_setbuf(struct AqvmBaseFile_File* stream, char* buffer) { int AqvmBaseFile_setvbuf(struct AqvmBaseFile_File* stream, char* buffer, int mode, size_t size) { - if (stream == NULL || stream->file == NULL || AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream)) { // TODO return -1; } diff --git a/aqvm/base/file/file.h b/aqvm/base/file/file.h index c268e3e..b84b4d9 100644 --- a/aqvm/base/file/file.h +++ b/aqvm/base/file/file.h @@ -15,9 +15,11 @@ struct AqvmBaseFile_File { AqvmBaseThreadingMutex_Mutex mutex; }; -int AqvmBaseFile_LockFile(struct AqvmBaseFile_File* file); +int AqvmBaseFile_LockFile(struct AqvmBaseFile_File* stream); -int AqvmBaseFile_UnlockFile(struct AqvmBaseFile_File* file); +int AqvmBaseFile_UnlockFile(struct AqvmBaseFile_File* stream); + +int AqvmBaseFile_CheckStream(struct AqvmBaseFile_File* stream); void AqvmBaseFile_clearerr(struct AqvmBaseFile_File* stream); diff --git a/aqvm/base/io/io.c b/aqvm/base/io/io.c index 7b15303..2208768 100644 --- a/aqvm/base/io/io.c +++ b/aqvm/base/io/io.c @@ -44,8 +44,7 @@ int AqvmBaseIo_CloseIo() { } int AqvmBaseIo_LockStream(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -65,11 +64,12 @@ int AqvmBaseIo_LockStream(struct AqvmBaseFile_File* stream) { return -4; } } + + return 0; } int AqvmBaseIo_UnlockStream(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -89,11 +89,16 @@ int AqvmBaseIo_UnlockStream(struct AqvmBaseFile_File* stream) { return -4; } } + + return 0; } -int AqvmBaseIo_OutputLog(struct AqvmBaseFile_File* stream, ...) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { +int AqvmBaseIo_OutputLog(struct AqvmBaseFile_File* stream, const char* time, + const char* type, const char* code, + const char* message, va_list system_info, + va_list other_info) { + if (AqvmBaseFile_CheckStream(stream) != 0 || time == NULL || type == NULL || + code == NULL || message == NULL) { // TODO return -1; } @@ -103,30 +108,51 @@ int AqvmBaseIo_OutputLog(struct AqvmBaseFile_File* stream, ...) { return -2; } - va_list arg; - va_start(arg, stream); - char* str = va_arg(arg, char*); - while (str != NULL) { - int result = fprintf(stream->file, "%s", str); - if (result < 0) { + if (fprintf( + stream->file, + "{\"Time\":\"%s\",\"Type\":\"%s\",\"Code\":\"%s\",\"Message\":\"%s\"", + time, type, code, message) < 0) { + // TODO + return -3; + } + + char* name = va_arg(system_info, char*); + char* value = va_arg(system_info, char*); + while (name != NULL && value != NULL) { + if (fprintf(stream->file, ",\"%s\":\"%s\"", name, value) < 0) { // TODO - return -3; + return -4; } - str = va_arg(arg, char*); + name = va_arg(system_info, char*); + value = va_arg(system_info, char*); + } + + name = va_arg(other_info, char*); + value = va_arg(other_info, char*); + while (name != NULL && value != NULL) { + if (fprintf(stream->file, ",\"%s\":\"%s\"", name, value) < 0) { + // TODO + return -5; + } + name = va_arg(other_info, char*); + value = va_arg(other_info, char*); + } + + if (fprintf(stream->file, "}\n") < 0) { + // TODO + return -6; } - va_end(arg); if (AqvmBaseIo_UnlockStream(stream) != 0) { // TODO - return -4; + return -7; } return 0; } int AqvmBaseIo_fgetc(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -2; } @@ -159,8 +185,7 @@ int AqvmBaseIo_fgetc(struct AqvmBaseFile_File* stream) { } char* AqvmBaseIo_fgets(char* str, int n, struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0 || str == NULL || n <= 0) { + if (str == NULL || n <= 0 || AqvmBaseFile_CheckStream(stream) != 0) { // TODO return NULL; } @@ -194,8 +219,7 @@ char* AqvmBaseIo_fgets(char* str, int n, struct AqvmBaseFile_File* stream) { int AqvmBaseIo_fprintf(struct AqvmBaseFile_File* stream, const char* format, ...) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0 || format == NULL) { + if (format == NULL || AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -228,8 +252,7 @@ int AqvmBaseIo_fprintf(struct AqvmBaseFile_File* stream, const char* format, } int AqvmBaseIo_fputc(int character, struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -2; } @@ -259,8 +282,7 @@ int AqvmBaseIo_fputc(int character, struct AqvmBaseFile_File* stream) { } int AqvmBaseIo_fputs(const char* str, struct AqvmBaseFile_File* stream) { - if (str == NULL || stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (str == NULL || AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -291,8 +313,7 @@ int AqvmBaseIo_fputs(const char* str, struct AqvmBaseFile_File* stream) { int AqvmBaseIo_fscanf(struct AqvmBaseFile_File* stream, const char* format, ...) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0 || format == NULL) { + if (format == NULL || AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -2; } @@ -325,8 +346,7 @@ int AqvmBaseIo_fscanf(struct AqvmBaseFile_File* stream, const char* format, } int AqvmBaseIo_getc(struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { return -2; } if (stream->file == stdout || stream->file == stderr) { @@ -359,7 +379,7 @@ int AqvmBaseIo_getc(struct AqvmBaseFile_File* stream) { } int AqvmBaseIo_getchar(void) { - if (AqvmBaseFile_ferror(AqvmBaseIo_stdin) != 0) { + if (AqvmBaseFile_CheckStream(AqvmBaseIo_stdin) != 0) { // TODO return -2; } @@ -389,7 +409,7 @@ int AqvmBaseIo_getchar(void) { } int AqvmBaseIo_perror(const char* str) { - if (str == NULL || AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + if (str == NULL || AqvmBaseFile_CheckStream(AqvmBaseIo_stderr) != 0) { return -1; } @@ -409,7 +429,7 @@ int AqvmBaseIo_perror(const char* str) { } int AqvmBaseIo_printf(const char* format, ...) { - if (format == NULL || AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + if (format == NULL || AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { return -1; } @@ -437,8 +457,7 @@ int AqvmBaseIo_printf(const char* format, ...) { } int AqvmBaseIo_putc(int character, struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -468,7 +487,7 @@ int AqvmBaseIo_putc(int character, struct AqvmBaseFile_File* stream) { } int AqvmBaseIo_putchar(int character) { - if (AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + if (AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -2; } @@ -494,7 +513,7 @@ int AqvmBaseIo_putchar(int character) { } int AqvmBaseIo_puts(const char* str) { - if (str == NULL || AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + if (str == NULL || AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -1; } @@ -520,7 +539,7 @@ int AqvmBaseIo_puts(const char* str) { } int AqvmBaseIo_scanf(const char* format, ...) { - if (format == NULL || AqvmBaseFile_ferror(AqvmBaseIo_stdin) != 0) { + if (format == NULL || AqvmBaseFile_CheckStream(AqvmBaseIo_stdin) != 0) { // TODO return -1; } @@ -550,7 +569,7 @@ int AqvmBaseIo_scanf(const char* format, ...) { int AqvmBaseIo_snprintf(char* str, size_t size, const char* format, ...) { if (str == NULL || format == NULL || - AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -1; } @@ -580,7 +599,7 @@ int AqvmBaseIo_snprintf(char* str, size_t size, const char* format, ...) { int AqvmBaseIo_sprintf(char* str, const char* format, ...) { if (str == NULL || format == NULL || - AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -1; } @@ -610,7 +629,7 @@ int AqvmBaseIo_sprintf(char* str, const char* format, ...) { int AqvmBaseIo_sscanf(const char* str, const char* format, ...) { if (str == NULL || format == NULL || - AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -1; } @@ -639,27 +658,30 @@ int AqvmBaseIo_sscanf(const char* str, const char* format, ...) { } int AqvmBaseIo_ungetc(int character, struct AqvmBaseFile_File* stream) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0) { + if (AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } + if (stream->file == stdout || stream->file == stderr) { + // TODO + return -2; + } if (AqvmBaseIo_LockStream(AqvmBaseIo_stdout) != 0) { // TODO - return -2; + return -3; } int result = ungetc(character, stream->file); if (AqvmBaseIo_UnlockStream(AqvmBaseIo_stdout) != 0) { // TODO - return -3; + return -4; } if (result == EOF) { // TODO - return -4; + return -5; } return result; @@ -667,8 +689,7 @@ int AqvmBaseIo_ungetc(int character, struct AqvmBaseFile_File* stream) { int AqvmBaseIo_vfprintf(struct AqvmBaseFile_File* stream, const char* format, va_list arg) { - if (stream == NULL || stream->file == NULL || - AqvmBaseFile_ferror(stream) != 0 || format == NULL) { + if (format == NULL || AqvmBaseFile_CheckStream(stream) != 0) { // TODO return -1; } @@ -698,7 +719,7 @@ int AqvmBaseIo_vfprintf(struct AqvmBaseFile_File* stream, const char* format, } int AqvmBaseIo_vprintf(const char* format, va_list arg) { - if (format == NULL || AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + if (format == NULL || AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { return -1; } @@ -724,7 +745,7 @@ int AqvmBaseIo_vprintf(const char* format, va_list arg) { int AqvmBaseIo_vsprintf(char* str, const char* format, va_list arg) { if (str == NULL || format == NULL || - AqvmBaseFile_ferror(AqvmBaseIo_stdout) != 0) { + AqvmBaseFile_CheckStream(AqvmBaseIo_stdout) != 0) { // TODO return -1; } diff --git a/aqvm/base/io/io.h b/aqvm/base/io/io.h index 5ae5a00..0ae7cdf 100644 --- a/aqvm/base/io/io.h +++ b/aqvm/base/io/io.h @@ -23,7 +23,10 @@ int AqvmBaseIo_LockStream(struct AqvmBaseFile_File* stream); int AqvmBaseIo_UnlockStream(struct AqvmBaseFile_File* stream); -int AqvmBaseIo_OutputToStream(struct AqvmBaseFile_File* stream, ...); +int AqvmBaseIo_OutputLog(struct AqvmBaseFile_File* stream, const char* time, + const char* type, const char* code, + const char* message, va_list system_info, + va_list other_info); int AqvmBaseIo_fgetc(struct AqvmBaseFile_File* stream); diff --git a/aqvm/base/logging/logging.c b/aqvm/base/logging/logging.c index 66df627..ee8c5de 100644 --- a/aqvm/base/logging/logging.c +++ b/aqvm/base/logging/logging.c @@ -15,31 +15,20 @@ #include "aqvm/base/io/io.h" void AqvmBaseLogging_OutputLog(const char* type, const char* code, - const char* message, const char* other_info) { + const char* message, ...) { char time_str[28]; time_t current_time = time(NULL); strftime(time_str, 28, "%Y-%m-%dT%H:%M:%S%z", localtime(¤t_time)); - const char* format = NULL; - - if (other_info != NULL) { - format = - "{\"Time\":\"%s\",\"Type\":\"%s\",\"Code\":\"%s\",\"Message\":\"%s\",%" - "s}\n"; - } - - AqvmBaseLogging_ProcessLog(format, time_str, type, code, message, other_info); + va_list other_info; + va_start(other_info, message); + AqvmBaseLogging_ProcessLog(time_str, type, code, message, other_info, "Test","This is a test.",NULL); + va_end(other_info); } -void AqvmBaseLogging_ProcessLog(const char* format, const char* time, - const char* type, const char* code, - const char* message, const char* other_info, - ...) { - if (format == NULL) { - format = - "{\"Time\":\"%s\",\"Type\":\"%s\",\"Code\":\"%s\",\"Message\":\"%s\"}" - "\n"; - } +void AqvmBaseLogging_ProcessLog(const char* time, const char* type, + const char* code, const char* message, + va_list other_info, ...) { if (time == NULL) { time = "NULL"; } @@ -53,42 +42,44 @@ void AqvmBaseLogging_ProcessLog(const char* format, const char* time, message = "NULL"; } - AqvmBaseLogging_OutputLogToConsole(format, time, type, code, message, - other_info); - AqvmBaseLogging_OutputLogToFile(format, time, type, code, message, - other_info); + va_list system_info; + va_start(system_info, other_info); + AqvmBaseLogging_OutputLogToConsole(time, type, code, message, other_info, + system_info); + AqvmBaseLogging_OutputLogToFile(time, type, code, message, other_info, + system_info); + va_end(system_info); } -int AqvmBaseLogging_OutputLogToConsole(const char* format, ...) { - va_list args; - va_start(args, format); - - int result = AqvmBaseIo_vfprintf(AqvmBaseIo_stderr, format, args); +int AqvmBaseLogging_OutputLogToConsole(const char* time, const char* type, + const char* code, const char* message, + va_list system_info, + va_list other_info) { + int result = AqvmBaseIo_OutputLog(AqvmBaseIo_stderr, time, type, code, + message, system_info, other_info); if (result != 0) { // TODO return -1; } - - va_end(args); - return result; + return 0; } -int AqvmBaseLogging_OutputLogToFile(const char* format, ...) { +int AqvmBaseLogging_OutputLogToFile(const char* time, const char* type, + const char* code, const char* message, + va_list system_info, va_list other_info) { struct AqvmBaseFile_File* log_ptr = AqvmBaseFile_fopen(".aqvm_log.log", "a"); if (log_ptr == NULL) { return -1; } - va_list args; - va_start(args, format); - - int result = AqvmBaseIo_vfprintf(log_ptr, format, args); + int result = AqvmBaseIo_OutputLog(log_ptr, time, type, code, message, + system_info, other_info); if (result != 0) { // TODO return -2; } - va_end(args); AqvmBaseFile_fclose(log_ptr); - return result; + + return 0; } \ No newline at end of file diff --git a/aqvm/base/logging/logging.h b/aqvm/base/logging/logging.h index 2983465..2cf345c 100644 --- a/aqvm/base/logging/logging.h +++ b/aqvm/base/logging/logging.h @@ -5,6 +5,7 @@ #ifndef AQ_AQVM_BASE_LOGGING_LOGGING_H_ #define AQ_AQVM_BASE_LOGGING_LOGGING_H_ +#include #include // Outputs log with |type|, |code|, |message|, |other_info|, time, errno and so @@ -22,15 +23,18 @@ // is json format. For example, AqvmBaseLogging_OutputLog("type", // "code", "message", "other_info"); void AqvmBaseLogging_OutputLog(const char* type, const char* code, - const char* message, const char* other_info); + const char* message, ...); -void AqvmBaseLogging_ProcessLog(const char* format, const char* time, - const char* type, const char* code, - const char* message, - const char* other_info, ...); +void AqvmBaseLogging_ProcessLog(const char* time, const char* type, + const char* code, const char* message, + va_list other_info, ...); -int AqvmBaseLogging_OutputLogToConsole(const char* format, ...); +int AqvmBaseLogging_OutputLogToConsole(const char* time, const char* type, + const char* code, const char* message, + va_list system_info, va_list other_info); -int AqvmBaseLogging_OutputLogToFile(const char* format, ...); +int AqvmBaseLogging_OutputLogToFile(const char* time, const char* type, + const char* code, const char* message, + va_list system_info, va_list other_info); #endif \ No newline at end of file