| 1 | const statement = require("./statement.js"); | 
| 2 | const event = require("./event.js"); | 
| 3 | const queue = require("./queue.js"); | 
| 4 | 
 | 
| 5 | class 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 | 
 | 
| 42 | module.exports = Logger; | 
| 43 | 
 |