cool stuff
This commit is contained in:
16
src/Log/Error.c
Normal file
16
src/Log/Error.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundLogError(const char* message) {
|
||||
if (Ground.Log.errorCount >= 4096) {
|
||||
Ground.Internal.giveUpAndCry();
|
||||
}
|
||||
|
||||
char* copy = malloc(sizeof(char) * (strlen(message) + 1));
|
||||
if (copy == NULL) {
|
||||
Ground.Internal.giveUpAndCry();
|
||||
}
|
||||
|
||||
strcpy(copy, message);
|
||||
Ground.Log.errors[Ground.Log.errorCount] = copy;
|
||||
Ground.Log.errorCount++;
|
||||
}
|
||||
16
src/Log/Warning.c
Normal file
16
src/Log/Warning.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundLogWarning(const char* message) {
|
||||
if (Ground.Log.warningCount >= 4096) {
|
||||
Ground.Internal.giveUpAndCry();
|
||||
}
|
||||
|
||||
char* copy = malloc(sizeof(char) * (strlen(message) + 1));
|
||||
if (copy == NULL) {
|
||||
Ground.Internal.giveUpAndCry();
|
||||
}
|
||||
|
||||
strcpy(copy, message);
|
||||
Ground.Log.warnings[Ground.Log.warningCount] = copy;
|
||||
Ground.Log.warningCount++;
|
||||
}
|
||||
16
src/Log/printErrors.c
Normal file
16
src/Log/printErrors.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundLogPrintErrors() {
|
||||
if (Ground.Log.errorCount != 0) {
|
||||
printf("%zu errors:\n", Ground.Log.errorCount);
|
||||
for (size_t i = 0; i < Ground.Log.errorCount; i++) {
|
||||
printf(" \e[0;31m%zu: %s\n\e[0m", Ground.Log.errorCount, Ground.Log.errors[i]);
|
||||
}
|
||||
}
|
||||
if (Ground.Log.warningCount != 0) {
|
||||
printf("%zu warnings:\n", Ground.Log.warningCount);
|
||||
for (size_t i = 0; i < Ground.Log.warningCount; i++) {
|
||||
printf(" \e[0;33m%zu: %s\n\e[0m", Ground.Log.warningCount, Ground.Log.warnings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user