diff --git a/liblog.a b/liblog.a new file mode 100644 index 0000000..636c722 Binary files /dev/null and b/liblog.a differ diff --git a/makefile b/makefile new file mode 100644 index 0000000..03bbd84 --- /dev/null +++ b/makefile @@ -0,0 +1,18 @@ +.POSIX: + +# Compiler and archiver definitions +CC = cc +AR = ar +CFLAGS = -O2 -I./source_code + +# Targets +all: liblog.a + +source_code/log.o: source_code/log.c source_code/log.h + $(CC) $(CFLAGS) -c source_code/log.c -o source_code/log.o + +liblog.a: source_code/log.o + $(AR) -rc liblog.a source_code/log.o + +clean: + rm -f source_code/log.o liblog.a diff --git a/source_code/new_log.c b/source_code/log.c similarity index 93% rename from source_code/new_log.c rename to source_code/log.c index 233c03b..13a97bf 100644 --- a/source_code/new_log.c +++ b/source_code/log.c @@ -22,6 +22,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * + * Original version can be found at: https://github.com/rxi/log.c * * Modified work Copyright (c) 2026 Emilia Marigold (AGPLv3) * @@ -33,12 +34,13 @@ * See the LICENSE file for the full AGPLv3 terms and conditions. ***/ -#include "new_log.h" +#include "log.h" #define MAX_CALLBACKS 32 typedef -struct callback_struct +struct +callback_struct { log_function function; void *user_data; @@ -46,7 +48,8 @@ struct callback_struct } callback_type; -static struct static_log_data_struct +static struct +static_log_data_struct { void *user_data; lock_function lock; @@ -62,7 +65,7 @@ level_strings[] = "TRACE", "DEBUG", "INFO", - "WARNING", + "WARN", "ERROR", "FATAL" }; @@ -84,10 +87,11 @@ static void stdout_callback(log_event_type *event) { char buffer[16]; + buffer[strftime(buffer, - sizeof(buffer), - "%H:%M:%S", - event->local_time)] = '\0'; + sizeof(buffer), + "%H:%M:%S", + event->local_time)] = '\0'; #ifdef LOG_USE_COLOR fprintf(event->user_data, @@ -122,9 +126,9 @@ file_callback(log_event_type *event) { char buffer[64]; buffer[strftime(buffer, - sizeof(buffer), - "%Y-%m-%d %H:%M:%S", - event->local_time)] = '\0'; + sizeof(buffer), + "%Y-%m-%d %H:%M:%S", + event->local_time)] = '\0'; fprintf(event->user_data, "%s %-5s %s:%d: ", @@ -275,7 +279,7 @@ log_log(int severity_level, for (int i = 0; i < MAX_CALLBACKS && static_log_data_struct.callbacks[i].function; - i++) + i++) { callback_type *callback_pointer = &static_log_data_struct.callbacks[i]; if (severity_level >= callback_pointer->severity_level) diff --git a/source_code/new_log.h b/source_code/log.h similarity index 97% rename from source_code/new_log.h rename to source_code/log.h index 1f1c9d0..1c47a27 100644 --- a/source_code/new_log.h +++ b/source_code/log.h @@ -16,10 +16,11 @@ #include #include -#define LOG_VERSION "r:2.26.180.1" +#define LOG_VERSION "2.26.180a" typedef -struct log_event_struct +struct +log_event_struct { va_list argument_pointer; const char *format; diff --git a/source_code/log.o b/source_code/log.o new file mode 100644 index 0000000..8589311 Binary files /dev/null and b/source_code/log.o differ