fixed some style issues.

This commit is contained in:
2026-07-21 13:32:06 -05:00
parent 9badfb3040
commit e2f5b8624d
5 changed files with 36 additions and 13 deletions

BIN
liblog.a Normal file

Binary file not shown.

18
makefile Normal file
View File

@@ -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

View File

@@ -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)

View File

@@ -16,10 +16,11 @@
#include <stdbool.h>
#include <time.h>
#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;

BIN
source_code/log.o Normal file

Binary file not shown.