diff options
author | Marvin Borner | 2023-05-26 18:08:09 +0200 |
---|---|---|
committer | Marvin Borner | 2023-05-26 18:09:39 +0200 |
commit | 464cca35825a02541efd46cfd3af91146c118d01 (patch) | |
tree | 2c9709cfbc9705d8d2c7eda481e81c6e1ff32ca7 /src/log.c | |
parent | b31220aadc24ff137a4fe4bc39780ae63c58e11b (diff) |
Becoming aggressive
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c new file mode 100644 index 0000000..a34c8e8 --- /dev/null +++ b/src/log.c @@ -0,0 +1,40 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> + +#include <log.h> + +static int debug_enabled = 0; + +void debug(const char *format, ...) +{ + if (!debug_enabled) + return; + + fprintf(stderr, "[DEBUG] "); + + va_list ap; + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); +} + +void debug_enable(int enable) +{ + debug_enabled = enable; +} + +void fatal(const char *format, ...) +{ + fprintf(stderr, "[FATAL] "); + + va_list ap; + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + + abort(); +} |