add formatting to lLogString
This commit is contained in:
22
LLog.c
22
LLog.c
@@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "time.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
int timer_array_append(timer_array* array, lTimer timer) {
|
||||
if (array->count >= array->capacity) {
|
||||
@@ -29,14 +30,23 @@ void stop_timer(Logger* logger, int timer_id) {
|
||||
logger->timers.items[timer_id].time.end = time(NULL);
|
||||
}
|
||||
|
||||
lLogString to_lLogString(const char* string) {
|
||||
lLogString lLogString_new(const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
char temp_string[max_string_len];
|
||||
vsnprintf(temp_string, max_string_len, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
lLogString str;
|
||||
str.buf = (char *)string;
|
||||
if (string == NULL) {
|
||||
str.len = 0;
|
||||
} else {
|
||||
str.len = strlen(string);
|
||||
str.len = strlen(temp_string);
|
||||
|
||||
str.buf = malloc(str.len + 1);
|
||||
if (str.buf != NULL) {
|
||||
strcpy(str.buf, temp_string);
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user