summaryrefslogtreecommitdiff
path: root/src/log.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2025-09-26 17:58:31 +0200
committerAldrik Ramaekers <aldrikboy@gmail.com>2025-09-26 17:58:31 +0200
commitfb8361d11bdf8c21d2e9d3b94bae444089ba0d96 (patch)
tree9ab563c0c3eefb71ee4a1db6079d58e377a252a3 /src/log.cpp
parente2321f28730adcb8d67800a434ebc7d60a6dcccb (diff)
log read and write failures
Diffstat (limited to 'src/log.cpp')
-rw-r--r--src/log.cpp46
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);
+}