57 fprintf(stderr,
"%-10s Error: ", label);
58 va_start(args, format);
59 vfprintf(stderr, format, args);
61 fprintf(stderr,
"\n");
64 fprintf(s->
log,
"%s Error: ", label);
65 va_start(args, format);
66 vfprintf(s->
log, format, args);
68 fprintf(s->
log,
"\n");
96 fprintf(stderr,
"%-10s Warning: ", label);
97 va_start(args, format);
98 vfprintf(stderr, format, args);
100 fprintf(stderr,
"\n");
103 fprintf(s->
log,
"%s Error: ", label);
104 va_start(args, format);
105 vfprintf(s->
log, format, args);
107 fprintf(s->
log,
"\n");
129 label =
"[Shutdown]";
137 fprintf(stdout,
"%-10s Info:%d: ", label, level);
138 va_start(args, format);
139 vfprintf(stdout, format, args);
141 fprintf(stdout,
"\n");
145 fprintf(s->
log,
"%s Info:%d: ", label, level);
146 va_start(args, format);
147 vfprintf(s->
log, format, args);
149 fprintf(s->
log,
"\n");
170 time_t now = time(NULL);
171 struct tm *tm = localtime(&now);
172 char *fileName = NULL;
174 strftime(date, 9,
"%Y%m%d", tm);
180 if (asprintf(&fileName,
"%s%s%02x.%s", prefix, date, i, extension) == -1) {
return NULL; }
182 file = fopen(fileName,
"w+x");
185 char *fStem = strndup(fileName, strlen(fileName) - strlen(extension) - 1);
191 if (errno != EEXIST) {
208 if (s->
log) { fclose(s->
log); }
void destroy_program_state(program_state *s)
Cleanly destroy program state.
FILE * openSerialNumberedFile(const char *prefix, const char *extension, char **name)
Open dated, serial numbered file with given prefix and extension.
void log_info(const program_state *s, const int level, const char *format,...)
Output formatted information message at a given level.
void log_warning(const program_state *s, const char *format,...)
Output formatted warning message.
void log_error(const program_state *s, const char *format,...)
Output formatted error message.
Program state and logging information.
int logverbose
Current log verbosity (file output)
int verbose
Current log verbosity (console output)
bool started
Indicates startup completed.
bool shutdown
Indicates shutdown begun.