From 81804532dfb0ebbaa8a134158ae6b16046c89a91 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Tue, 26 Dec 2017 16:44:28 -0600 Subject: [PATCH] Reorganize log.c --- include/log.h | 2 +- src/log.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/log.h b/include/log.h index 247ce2c..e671d51 100644 --- a/include/log.h +++ b/include/log.h @@ -17,9 +17,9 @@ enum log_errcode { ERR_GFXOP, // we couldn't execute a specific graphic operation }; -extern void log_write(int, const char *, ...); extern void log_close(); extern void log_open(FILE *); +extern void log_write(int, const char *, ...); /* * Here we have a couple of convenience macros that abstracts the log diff --git a/src/log.c b/src/log.c index 5db35e0..fdb9357 100644 --- a/src/log.c +++ b/src/log.c @@ -17,6 +17,19 @@ */ static FILE *log_stream = NULL; +/* + * Close the file stream we opened (or were given) in `log_open()`. + * Nota bene: if you passed stdout into log_open(), this will actually + * _close_ the stdout stream (!). + */ +void +log_close() +{ + if (log_stream != NULL) { + fclose(log_stream); + } +} + /* * This function will assign the log_stream variable to either a given * file stream, or if none given, to the default location (which is a @@ -39,19 +52,6 @@ log_open(FILE *stream) } } -/* - * Close the file stream we opened (or were given) in `log_open()`. - * Nota bene: if you passed stdout into log_open(), this will actually - * _close_ the stdout stream (!). - */ -void -log_close() -{ - if (log_stream != NULL) { - fclose(log_stream); - } -} - /* * Write to the log stream. This function can accept variable arguments, * ala `printf()`. There is some support for different log levels, but