Index

lognestmonster / 9e7f4df

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1825 Dec 2018 21:144e8c05eUpdate logger.jsJoshua11625N

Blob @ lognestmonster / src / logger.js

application/javascript1346 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 this.locations = {
9 "node": "./log/node"
10 }
11 if (config) {
12 if (config.name) {
13 if (typeof config.name != "string") throw new Error(`Expected string, got ${typeof config.name} for config.name`);
14 this.name = config.name;
15 }
16 if (config.locations) {
17 if (typeof config.locations != "object") throw new Error(`Expected object, got ${typeof config.locations} for config.locations`);
18 let locations = {};
19 Object.keys(config.locations).forEach(function (name) {
20 if (typeof name != "string") throw new Error(`Expected string, got ${typeof name} for config.locations key`);
21 let location = config.locations[name];
22 if (typeof location != "string") throw new Error(`Expected string, got ${typeof location} for config.locations value`);
23 locations[name] = new queue(name, location);
24 });
25 this.locations = locations;
26 }
27 }
28 return this;
29 }
30
31 queue(name) {
32 if (typeof name != "string") throw new Error(`Expect string, got ${typeof name} for name parameter`);
33 if (this.location[name] == null) throw new Error(`Requested queue, ${name}, is nonexistent`);
34 return this.locations[name];
35 }
36}
37
38module.exports = Logger;
39