Index

lognestmonster / 08ae872

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
3826 Dec 2018 11:3708ae872Update logger.jsJoshua101N

Blob @ lognestmonster / src / logger.js

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