Index

lognestmonster / e54fd6e

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
5928 Dec 2018 00:060a557d5Update logger init for queue compactionJoshua161N

Blob @ lognestmonster / src / logger.js

application/javascript1458 bytesdownload raw
1const statement = require("./statement.js");
2const event = require("./event.js");
3const queue = require("./queue.js");
4
5class Logger {
6 constructor(config) {
7 this.name = "Logger";
8 let locations = {
9 "node": "./log/node"
10 }
11 let compact = false;
12 if (config) {
13 if (config.name) {
14 if (typeof config.name != "string") throw new TypeError(`Expected string, got ${typeof config.name} for config.name`);
15 this.name = config.name;
16 }
17 if (config.locations) {
18 if (typeof config.locations != "object") throw new TypeError(`Expected object, got ${typeof config.locations} for config.locations`);
19 locations = config.locations;
20 }
21 if (config.compact) {
22 if (typeof config.compact != "boolean") throw new TypeError(`Expected boolean, got ${typeof config.compact} for config.compact`);
23 compact = config.compact;
24 }
25 }
26 Object.keys(locations).forEach(function (name) {
27 let location = locations[name];
28 if (typeof location != "string") throw new TypeError(`Expected string, got ${typeof location} for location`);
29 locations[name] = new queue(name, location, {compact: compact});
30 });
31 this.locations = locations;
32 return this;
33 }
34
35 queue(name) {
36 if (typeof name != "string") throw new TypeError(`Expect string, got ${typeof name} for name parameter`);
37 if (this.locations[name] == null) throw new TypeError(`Requested queue, ${name}, is nonexistent`);
38 return this.locations[name];
39 }
40}
41
42module.exports = Logger;
43