Index

lognestmonster / 1e47a58

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4026 Dec 2018 13:255a8d3d4Update logger.jsJoshua188N

Blob @ lognestmonster / src / logger.js

application/javascript1221 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 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 locations = config.locations;
19 }
20 }
21 Object.keys(locations).forEach(function (name) {
22 let location = locations[name];
23 if (typeof location != "string") throw new TypeError(`Expected string, got ${typeof location} for location`);
24 locations[name] = new queue(name, location);
25 });
26 this.locations = locations;
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