Index

lognestmonster / b6b260e

A general-purpose single-header C logging library and parser for event-based logs. (Incomplete)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
15329 Nov 2019 19:38b6b260eAdd header protection for one-time definitionsJosh Stockin1102N

Blob @ lognestmonster / tests / main.c

text/plain2958 bytesdownload raw
1// lognestmonster Copyright (c) 2019 Joshua 'joshuas3' Stockin
2// main.c
3// C file for testing the lognestmonster library header
4
5// <https://github.com/JoshuaS3/lognestmonster/>.
6
7
8// This file is part of lognestmonster.
9
10// lognestmonster is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14
15// lognestmonster is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19
20// You should have received a copy of the GNU General Public License
21// along with lognestmonster. If not, see <https://www.gnu.org/licenses/>.
22
23#include <stdio.h>
24
25#define DEFINE_LOGNESTMONSTER
26#include "lognestmonster.h"
27
28void test(void);
29extern char * queueName;
30static char * queuePath = "~/path";
31
32int main(void) {
33 queueName = "master";
34 long t1 = lnm_getus();
35
36 printf("lognestmonster C test main()\n");
37 printf("============================\n");
38 printf("\n\n");
39
40
41 printf("data testing\n");
42 printf("----------------------------\n");
43
44 printf("word size/ptr length: %li\n", sizeof(lnmItem));
45 printf("\n");
46
47 printf("enum lnmVerbosityLevel {\n");
48 printf("\tlnmInfo = %i,\n\tlnmDebug = %i,\n\tlnmVerbose = %i,\n\tlnmVeryVerbose = %i,\n\tlnmWarning = %i,\n\tlnmError = %i\n}\n", lnmInfo, lnmDebug, lnmVerbose, lnmVeryVerbose, lnmWarning, lnmError);
49 printf("\n\n");
50
51 printf("core library\n");
52 printf("----------------------------\n");
53
54 printf("creating \"%s\" queue with path \"%s\"\n", queueName, queuePath);
55 lnmQueue queue = lnmQueueInit(queueName, queuePath);
56 printf("queue \"%s\" created at 0x%llx\n", queueName, (long long)queue);
57 printf("\n");
58
59 printf("checking queue integrity in registry...\n");
60 printf("queue == lnmQueueByName(\"%s\"): ", queueName);
61 if (queue == lnmQueueByName(queueName)) {
62 printf("true\n");
63 } else {
64 printf("false. exiting...\n");
65 return 1;
66 }
67 printf("\n");
68
69 printf("creating an E{3S} logtree\n");
70 lnmItem event = lnmEventS(lnmError, "Tag / Invoker", "Test ERROR statement pushed to single event with custom tag and message");
71 lnmEventPushS(event, lnmInfo, "INIT", "Sample INFO/INIT log statement");
72 lnmEventPushS(event, lnmDebug, "SERVER", "DEBUG/SERVER log statement. might be found useful in a webserver backend");
73 printf("\n");
74
75 printf("debug registry logtree (1 top level items expected)\n");
76 lnm_debug_parse_registry();
77 printf("\n");
78
79 printf("calling test function from different source file\n");
80 test();
81 printf("\n");
82
83 printf("freeing registry\n");
84 lnm_free_registry();
85 lnm_debug_parse_registry();
86 printf("\n\n");
87
88 printf("tests finished\n");
89 printf("----------------------------\n");
90 printf("time elapsed (us): %lu\n", lnm_getus() - t1);
91
92 return 0;
93}
94