diff options
Diffstat (limited to 'src/log.cpp')
| -rw-r--r-- | src/log.cpp | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/log.cpp b/src/log.cpp index 270a636..839ebbe 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -27,12 +27,10 @@ log* get_log() return &g_log; } -void log_add(const char* fmt, ...) +static void log_message(const char* fmt, ImVec4 color, va_list args) { - va_list args; - va_start(args, fmt); vsnprintf(g_log.history[g_log.write_cursor], MAX_LEN_LOG_TXT, fmt, args); - va_end(args); + g_log.colors[g_log.write_cursor] = color; tick_t ms_since_epoch = timer_system(); char time_buf[50]; @@ -64,3 +62,43 @@ void log_add(const char* fmt, ...) g_log.history_length++; if (g_log.history_length > MAX_LEN_LOG_HISTORY) g_log.history_length = MAX_LEN_LOG_HISTORY; } + +void log_aerr(a_err errors) +{ + if (errors & A_ERR_GENERIC) log_error(" ERROR: Generic error"); + if (errors & A_ERR_NOT_FOUND) log_error(" ERROR: Not found"); + if (errors & A_ERR_MISSING_DESCRIPTION) log_error(" ERROR: Missing description"); + if (errors & A_ERR_CODE_EXISTS) log_error(" ERROR: Code already exists"); + if (errors & A_ERR_MISSING_BILLING_ITEMS) log_error(" ERROR: Missing billing items"); + if (errors & A_ERR_INVALID_ADDRESSEE) log_error(" ERROR: Invalid addressee"); + if (errors & A_ERR_INVALID_CUSTOMER) log_error(" ERROR: Invalid customer"); + if (errors & A_ERR_INVALID_SUPPLIER) log_error(" ERROR: Invalid supplier"); + if (errors & A_ERR_MISSING_NAME) log_error(" ERROR: Missing name"); + if (errors & A_ERR_MISSING_CITY) log_error(" ERROR: Missing city"); + if (errors & A_ERR_MISSING_POSTAL) log_error(" ERROR: Missing postal code"); + if (errors & A_ERR_MISSING_ADDRESS1) log_error(" ERROR: Missing address line 1"); + if (errors & A_ERR_MISSING_COUNTRYCODE) log_error(" ERROR: Missing country code"); + if (errors & A_ERR_MISSING_TAXID) log_error(" ERROR: Missing tax ID"); + if (errors & A_ERR_MISSING_BUSINESSID) log_error(" ERROR: Missing business ID"); + if (errors & A_ERR_MAX_ITEMS_REACHED) log_error(" ERROR: Maximum items reached"); + if (errors & A_ERR_MISSING_CODE) log_error(" ERROR: Missing code"); + if (errors & A_ERR_MISSING_EMAIL) log_error(" ERROR: Missing email"); + if (errors & A_ERR_MISSING_TAX_RATE) log_error(" ERROR: Missing tax rate"); + if (errors & A_ERR_INVALID_BILLING_ITEM) log_error(" ERROR: Invalid billing item"); +} + +void log_error(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + log_message(fmt, ImVec4(1,0,0,1), args); + va_end(args); +} + +void log_info(const char* fmt, ...) +{ + va_list args; + va_start(args, fmt); + log_message(fmt, ImVec4(1,1,1,1), args); + va_end(args); +} |
