UNPKG

2.07 kBJavaScriptView Raw
1"use strict";
2/**
3 * Simple console logger.
4 */
5var Logger = (function () {
6 function Logger(options) {
7 if (options === void 0) { options = {}; }
8 this.options = options;
9 /**
10 * The function to use to log info level messages.
11 */
12 this.infofn = console.log.bind(console);
13 /**
14 * The function to use to log warn level messages.
15 */
16 this.warnfn = console.warn.bind(console);
17 /**
18 * The function to use to log error level messages.
19 */
20 this.errorfn = console.error.bind(console);
21 }
22 /**
23 * Send a log at info level.
24 *
25 * @note TODO: Fix optionalParams in docs.
26 *
27 * @param message - The message to log.
28 */
29 Logger.prototype.info = function (message) {
30 var optionalParams = [];
31 for (var _i = 1; _i < arguments.length; _i++) {
32 optionalParams[_i - 1] = arguments[_i];
33 }
34 if (!this.options.silent) {
35 this.infofn.apply(this, [message].concat(optionalParams));
36 }
37 };
38 /**
39 * Send a log at warn level.
40 *
41 * @note TODO: Fix optionalParams in docs.
42 *
43 * @param message - The message to log.
44 */
45 Logger.prototype.warn = function (message) {
46 var optionalParams = [];
47 for (var _i = 1; _i < arguments.length; _i++) {
48 optionalParams[_i - 1] = arguments[_i];
49 }
50 if (!this.options.silent) {
51 this.warnfn.apply(this, [message].concat(optionalParams));
52 }
53 };
54 /**
55 * Send a log at error level.
56 *
57 * @note TODO: Fix optionalParams in docs.
58 *
59 * @param message - The message to log.
60 */
61 Logger.prototype.error = function (message) {
62 var optionalParams = [];
63 for (var _i = 1; _i < arguments.length; _i++) {
64 optionalParams[_i - 1] = arguments[_i];
65 }
66 this.errorfn.apply(this, [message].concat(optionalParams));
67 };
68 return Logger;
69}());
70exports.Logger = Logger;
71//# sourceMappingURL=logger.js.map
\No newline at end of file