mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-27 20:51:17 +00:00
Reorganize log.c
This commit is contained in:
parent
68084cc0c3
commit
81804532df
@ -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
|
||||
|
26
src/log.c
26
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
|
||||
|
Loading…
Reference in New Issue
Block a user