OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
stream.c
Go to the documentation of this file.
1 #include "olog.h"
2 #include "olog/stream.h"
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 static int olog_backend_stream_print(olog *olog, olog_backend *backend, uint8_t severity, va_list args) {
8  const char* format = va_arg(args, const char*);
9  int ret = vfprintf((FILE*) backend->data, format, args);
10  return ret < 0 ? OLOG_EXPLODED : 0;
11 }
12 
13 olog_backend olog_backend_stream(FILE *stream, int8_t min_log_level, int8_t max_log_level) {
14  olog_backend ret = {
15  .min_log_level = min_log_level,
16  .max_log_level = max_log_level,
17  .data = stream,
18  .print_callback = olog_backend_stream_print,
19  .destroy_callback = NULL
20  };
21  return ret;
22 }
#define NULL
Definition: decode_rs.h:63
olog_backend olog_backend_stream(FILE *stream, int8_t min_log_level, int8_t max_log_level)
Definition: stream.c:13
int8_t min_log_level
Minimum log level to receive.
Definition: olog.h:66
A simple logger, capable of dispatching log events to multiple end points.
Definition: olog.c:11
void * data
Storage for backend use.
Definition: olog.h:84
#define OLOG_EXPLODED
Definition: olog.h:53
format
Definition: mapgen.py:185