Index

lognestmonster / 9d96bcb

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
14725 Nov 2019 19:429d96bcbRegistry/item memory managementJosh Stockin1103N

Blob @ lognestmonster / tests / main.c

text/plain2804 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#include "lognestmonster.h"
25
26static char * queueName = "master";
27static char * queuePath = "~/path";
28
29int main(void) {
30 long t1 = lnm_getus();
31
32 printf("lognestmonster C test main()\n");
33 printf("============================\n");
34 printf("\n\n");
35
36
37 printf("data testing\n");
38 printf("----------------------------\n");
39
40 printf("word size/ptr length: %li\n", sizeof(lnmItem));
41 printf("\n");
42
43 printf("enum lnmVerbosityLevel {\n");
44 printf("\tlnmInfo = %d,\n\tlnmDebug = %d,\n\tlnmVerbose = %d,\n\tlnmVeryVerbose = %d,\n\tlnmWarning = %d,\n\tlnmError = %d\n}\n", lnmInfo, lnmDebug, lnmVerbose, lnmVeryVerbose, lnmWarning, lnmError);
45 printf("\n\n");
46
47 printf("core library\n");
48 printf("----------------------------\n");
49
50 printf("creating \"%s\" queue with path \"%s\"\n", queueName, queuePath);
51 lnmQueue queue = lnmQueueInit(queueName, queuePath);
52 printf("queue \"%s\" created at 0x%lx\n", queueName, (long)queue);
53 printf("\n");
54
55 printf("checking queue integrity in registry...\n");
56 printf("queue == lnmQueueByName(\"%s\"): ", queueName);
57 if (queue == lnmQueueByName(queueName)) {
58 printf("true\n");
59 } else {
60 printf("false. exiting...\n");
61 return 1;
62 }
63 printf("\n");
64
65 printf("creating an E{3S} logtree\n");
66 lnmItem event = lnmEventS(lnmError, "Tag / Invoker", "Test ERROR statement pushed to single event with custom tag and message");
67 lnmEventPushS(event, lnmInfo, "INIT", "Sample INFO/INIT log statement");
68 lnmEventPushS(event, lnmDebug, "SERVER", "DEBUG/SERVER log statement. might be found useful in a webserver backend");
69 printf("\n");
70
71 printf("debug registry logtree (3 top level items expected)\n");
72 lnm_debug_parse_registry();
73 printf("\n");
74
75 printf("freeing registry\n");
76 lnm_free_registry();
77 lnm_debug_parse_registry();
78 printf("\n\n");
79
80 printf("tests finished\n");
81 printf("----------------------------\n");
82 printf("time elapsed (us): %li\n", lnm_getus() - t1);
83
84 return 0;
85}
86