-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslog_test.c
More file actions
26 lines (19 loc) · 847 Bytes
/
slog_test.c
File metadata and controls
26 lines (19 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <slog/slog.h>
#include <stdio.h>
void callback(void* userState, uint64_t logLen, const char* log) {
printf(log);
}
int main(int argc, const char** argv) {
SLogger logger = {0};
slogLoggerCreate(&logger, "main", NULL, SLOG_LOGGER_FEATURE_LOG2CUSTOM_OUT | SLOG_LOGGER_FEATURE_LOG2CONSOLE);
slogLoggerSetOutFileName(&logger, "main.txt");
slogLoggerSetCustomOutCallback(&logger, NULL, callback);
slogLogMsg(&logger, SLOG_SEVERITY_WARN, "Hello %d", 5);
slogLogMsg(&logger, SLOG_SEVERITY_INFO, "Hello %d", 5);
slogLogMsg(&logger, SLOG_SEVERITY_DEBUG, "Hello %d", 5);
slogLogMsg(&logger, SLOG_SEVERITY_ERROR, "Hello %d", 5);
slogLogMsg(&logger, SLOG_SEVERITY_FATAL, "Hello %d", 5);
slogLogMsg(&logger, SLOG_SEVERITY_CUSTOM, "Hello %d", 5);
slogLoggerDestroy(&logger);
return 0;
}