@spinajs/log 1.0.10 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/config/log.d.ts +9 -0
  2. package/lib/config/log.js +16 -0
  3. package/lib/config/log.js.map +1 -0
  4. package/lib/decorators.d.ts +6 -0
  5. package/lib/decorators.js +37 -0
  6. package/lib/decorators.js.map +1 -0
  7. package/lib/index.d.ts +12 -225
  8. package/lib/index.js +13 -197
  9. package/lib/index.js.map +1 -1
  10. package/lib/log.d.ts +70 -0
  11. package/lib/log.js +218 -0
  12. package/lib/log.js.map +1 -0
  13. package/lib/logger.d.ts +8 -0
  14. package/lib/logger.js +40 -0
  15. package/lib/logger.js.map +1 -0
  16. package/lib/schemas/log.configuration.d.ts +115 -0
  17. package/lib/schemas/log.configuration.js +136 -0
  18. package/lib/schemas/log.configuration.js.map +1 -0
  19. package/lib/targets/BlackHoleTarget.d.ts +8 -0
  20. package/lib/targets/BlackHoleTarget.js +25 -0
  21. package/lib/targets/BlackHoleTarget.js.map +1 -0
  22. package/lib/targets/ColoredConsoleTarget.d.ts +51 -0
  23. package/lib/targets/ColoredConsoleTarget.js +57 -0
  24. package/lib/targets/ColoredConsoleTarget.js.map +1 -0
  25. package/lib/targets/FileTarget.d.ts +24 -0
  26. package/lib/targets/FileTarget.js +193 -0
  27. package/lib/targets/FileTarget.js.map +1 -0
  28. package/lib/targets/LogTarget.d.ts +14 -0
  29. package/lib/targets/LogTarget.js +79 -0
  30. package/lib/targets/LogTarget.js.map +1 -0
  31. package/lib/targets/index.d.ts +3 -0
  32. package/lib/targets/index.js +16 -0
  33. package/lib/targets/index.js.map +1 -0
  34. package/lib/types.d.ts +145 -0
  35. package/lib/types.js +38 -0
  36. package/lib/types.js.map +1 -0
  37. package/lib/variables/date.d.ts +17 -0
  38. package/lib/variables/date.js +62 -0
  39. package/lib/variables/date.js.map +1 -0
  40. package/lib/variables/env.d.ts +5 -0
  41. package/lib/variables/env.js +25 -0
  42. package/lib/variables/env.js.map +1 -0
  43. package/lib/variables/index.d.ts +3 -0
  44. package/lib/variables/index.js +16 -0
  45. package/lib/variables/index.js.map +1 -0
  46. package/lib/variables/process.d.ts +6 -0
  47. package/lib/variables/process.js +36 -0
  48. package/lib/variables/process.js.map +1 -0
  49. package/package.json +21 -8
  50. package/yarn-error.log +2304 -13
@@ -0,0 +1,9 @@
1
+ declare const config: {
2
+ system: {
3
+ dirs: {
4
+ schemas: string[];
5
+ };
6
+ };
7
+ log: {};
8
+ };
9
+ export default config;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ function dir(path) {
5
+ return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(__dirname, path)));
6
+ }
7
+ const config = {
8
+ system: {
9
+ dirs: {
10
+ schemas: [dir('./../schemas')],
11
+ }
12
+ },
13
+ log: {}
14
+ };
15
+ exports.default = config;
16
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/config/log.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAa;IACtB,OAAO,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,MAAM,GAAG;IACX,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SACjC;KACJ;IACD,GAAG,EAAE,EAEJ;CACJ,CAAA;AAED,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Creates ( if not exists ) new logger instance with given name and optional variables
3
+ * @param name name of logger
4
+ * @param variables optional log variables
5
+ */
6
+ export declare function Logger(name: string, variables?: {}): (target: any, key: string) => any;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ const di_1 = require("@spinajs/di");
5
+ const log_1 = require("./log");
6
+ /**
7
+ * Creates ( if not exists ) new logger instance with given name and optional variables
8
+ * @param name name of logger
9
+ * @param variables optional log variables
10
+ */
11
+ function Logger(name, variables) {
12
+ return (target, key) => {
13
+ let logger;
14
+ // property getter
15
+ const getter = () => {
16
+ if (!logger) {
17
+ const allLoggers = di_1.DI.get(Array.ofType(log_1.Log));
18
+ const found = allLoggers.find(l => l.Name);
19
+ if (found) {
20
+ logger = found;
21
+ }
22
+ else {
23
+ logger = di_1.DI.resolve(log_1.Log, [name, variables]);
24
+ }
25
+ }
26
+ return logger;
27
+ };
28
+ // Create new property with getter and setter
29
+ Object.defineProperty(target, key, {
30
+ get: getter,
31
+ enumerable: false,
32
+ configurable: false
33
+ });
34
+ };
35
+ }
36
+ exports.Logger = Logger;
37
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AACjC,+BAA4B;AAG5B;;;;GAIG;AACH,SAAgB,MAAM,CAAC,IAAY,EAAE,SAAc;IAC/C,OAAO,CAAC,MAAW,EAAE,GAAW,EAAO,EAAE;QACrC,IAAI,MAAW,CAAC;QAEhB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,IAAI,CAAC,MAAM,EAAE;gBAET,MAAM,UAAU,GAAG,OAAE,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAG,CAAC,CAAC,CAAC;gBAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAE3C,IAAI,KAAK,EAAE;oBACP,MAAM,GAAG,KAAK,CAAC;iBAClB;qBAAM;oBACH,MAAM,GAAG,OAAE,CAAC,OAAO,CAAC,SAAG,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;iBAC/C;aACJ;YACD,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC;QAEF,6CAA6C;QAC7C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YAC/B,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACtB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AA3BD,wBA2BC"}
package/lib/index.d.ts CHANGED
@@ -1,227 +1,14 @@
1
- /// <reference types="node" />
2
- import { Writable } from "stream";
3
- import { Configuration } from "@spinajs/configuration";
4
- import { SyncModule } from "@spinajs/di";
5
1
  /**
6
- * -----------------------------------------------------------------------------------
7
- * IMPORTANT: log subsystem is havily based on bunyan. It uses bunyan by default, all options & functions are based on
8
- * bunyan lib. However you can implement custom log module and inject it to framework simply by implementing
9
- * `LogModule` that returns custom implementation of `Log` interface. Then override default DI registered class at app bootstrap.
2
+ * We export default configuration for webpack modules
3
+ * Normally we load configuration from disk via filesystem
4
+ * But webpack is bundlig all files into one.
10
5
  *
11
- * If you simply want to add more places where log goes eg. database, simply add custom log stream to configuration file.
12
- */
13
- /**
14
- * Creates child logger
15
- *
16
- * @param options - additional logger options
17
- */
18
- export declare function Logger(options?: any): (target?: any, key?: string) => any;
19
- /**
20
- * Log stream that writes messages in console with proper colours for message types.
21
- * * TRACE - gray
22
- * * DEBUG - white
23
- * * INFO - cyan
24
- * * WARN - yellow
25
- * * ERROR - red
26
- * * FATAL - red on white background
27
- */
28
- export declare class ConsoleLogStream extends Writable {
29
- private TRACE;
30
- private DEBUG;
31
- private INFO;
32
- private WARN;
33
- private ERROR;
34
- private FATAL;
35
- write(chunk: any): boolean;
36
- private _getNameFromType;
37
- }
38
- /**
39
- * Default log implementation interface. Taken from bunyan. Feel free to implement own.
40
- */
41
- export interface Log {
42
- /**
43
- * Returns a boolean: is the `trace` level enabled?
44
- *
45
- * This is equivalent to `log.isTraceEnabled()` or `log.isEnabledFor(TRACE)` in log4j.
46
- */
47
- trace(): boolean;
48
- /**
49
- * Special case to log an `Error` instance to the record.
50
- * This adds an `err` field with exception details
51
- * (including the stack) and sets `msg` to the exception
52
- * message or you can specify the `msg`.
53
- */
54
- trace(error: Error, ...params: any[]): void;
55
- /**
56
- * The first field can optionally be a "fields" object, which
57
- * is merged into the log record.
58
- *
59
- * To pass in an Error *and* other fields, use the `err`
60
- * field name for the Error instance.
61
- */
62
- trace(obj: Object, ...params: any[]): void;
63
- /**
64
- * Uses `util.format` for msg formatting.
65
- */
66
- trace(format: any, ...params: any[]): void;
67
- /**
68
- * Returns a boolean: is the `debug` level enabled?
69
- *
70
- * This is equivalent to `log.isDebugEnabled()` or `log.isEnabledFor(DEBUG)` in log4j.
71
- */
72
- debug(): boolean;
73
- /**
74
- * Special case to log an `Error` instance to the record.
75
- * This adds an `err` field with exception details
76
- * (including the stack) and sets `msg` to the exception
77
- * message or you can specify the `msg`.
78
- */
79
- debug(error: Error, ...params: any[]): void;
80
- /**
81
- * The first field can optionally be a "fields" object, which
82
- * is merged into the log record.
83
- *
84
- * To pass in an Error *and* other fields, use the `err`
85
- * field name for the Error instance.
86
- */
87
- debug(obj: Object, ...params: any[]): void;
88
- /**
89
- * Uses `util.format` for msg formatting.
90
- */
91
- debug(format: any, ...params: any[]): void;
92
- /**
93
- * Returns a boolean: is the `info` level enabled?
94
- *
95
- * This is equivalent to `log.isInfoEnabled()` or `log.isEnabledFor(INFO)` in log4j.
96
- */
97
- info(): boolean;
98
- /**
99
- * Special case to log an `Error` instance to the record.
100
- * This adds an `err` field with exception details
101
- * (including the stack) and sets `msg` to the exception
102
- * message or you can specify the `msg`.
103
- */
104
- info(error: Error, ...params: any[]): void;
105
- /**
106
- * The first field can optionally be a "fields" object, which
107
- * is merged into the log record.
108
- *
109
- * To pass in an Error *and* other fields, use the `err`
110
- * field name for the Error instance.
111
- */
112
- info(obj: Object, ...params: any[]): void;
113
- /**
114
- * Uses `util.format` for msg formatting.
115
- */
116
- info(format: any, ...params: any[]): void;
117
- /**
118
- * Returns a boolean: is the `warn` level enabled?
119
- *
120
- * This is equivalent to `log.isWarnEnabled()` or `log.isEnabledFor(WARN)` in log4j.
121
- */
122
- warn(): boolean;
123
- /**
124
- * Special case to log an `Error` instance to the record.
125
- * This adds an `err` field with exception details
126
- * (including the stack) and sets `msg` to the exception
127
- * message or you can specify the `msg`.
128
- */
129
- warn(error: Error, ...params: any[]): void;
130
- /**
131
- * The first field can optionally be a "fields" object, which
132
- * is merged into the log record.
133
- *
134
- * To pass in an Error *and* other fields, use the `err`
135
- * field name for the Error instance.
136
- */
137
- warn(obj: Object, ...params: any[]): void;
138
- /**
139
- * Uses `util.format` for msg formatting.
140
- */
141
- warn(format: any, ...params: any[]): void;
142
- /**
143
- * Returns a boolean: is the `error` level enabled?
144
- *
145
- * This is equivalent to `log.isErrorEnabled()` or `log.isEnabledFor(ERROR)` in log4j.
146
- */
147
- error(): boolean;
148
- /**
149
- * Special case to log an `Error` instance to the record.
150
- * This adds an `err` field with exception details
151
- * (including the stack) and sets `msg` to the exception
152
- * message or you can specify the `msg`.
153
- */
154
- error(error: Error, ...params: any[]): void;
155
- /**
156
- * The first field can optionally be a "fields" object, which
157
- * is merged into the log record.
158
- *
159
- * To pass in an Error *and* other fields, use the `err`
160
- * field name for the Error instance.
161
- */
162
- error(obj: Object, ...params: any[]): void;
163
- /**
164
- * Uses `util.format` for msg formatting.
165
- */
166
- error(format: any, ...params: any[]): void;
167
- /**
168
- * Returns a boolean: is the `fatal` level enabled?
169
- *
170
- * This is equivalent to `log.isFatalEnabled()` or `log.isEnabledFor(FATAL)` in log4j.
171
- */
172
- fatal(): boolean;
173
- /**
174
- * Special case to log an `Error` instance to the record.
175
- * This adds an `err` field with exception details
176
- * (including the stack) and sets `msg` to the exception
177
- * message or you can specify the `msg`.
178
- */
179
- fatal(error: Error, ...params: any[]): void;
180
- /**
181
- * The first field can optionally be a "fields" object, which
182
- * is merged into the log record.
183
- *
184
- * To pass in an Error *and* other fields, use the `err`
185
- * field name for the Error instance.
186
- */
187
- fatal(obj: Object, ...params: any[]): void;
188
- /**
189
- * Uses `util.format` for msg formatting.
190
- */
191
- fatal(format: any, ...params: any[]): void;
192
- child(options: Object, simple?: boolean): Log;
193
- }
194
- /**
195
- * Abstract class to implement for framework log module.
196
- */
197
- export declare abstract class LogModule extends SyncModule {
198
- abstract getLogger(options?: any): Log;
199
- }
200
- /**
201
- * Default Log implementation that uses bunyan internally. Feel free to implement own
202
- */
203
- export declare class SpinaJsDefaultLog extends LogModule {
204
- /**
205
- * Injected Configuration object
206
- */
207
- cfg: Configuration;
208
- /**
209
- * root logger
210
- * @access protected
211
- */
212
- protected log: Log;
213
- /**
214
- * Name of module
215
- * @access protected
216
- */
217
- protected name: string;
218
- /**
219
- * Creates child logger
220
- * @param options - additional logger options eg. fields.
221
- */
222
- getLogger(options?: any): Log;
223
- /**
224
- * Initializes bunyan logger & hooks for process:uncaughtException to log fatal application events
225
- */
226
- resolve(): void;
227
- }
6
+ * When we export, we can see configuration variable
7
+ * in webpack module cache and webpack config loader can see it
8
+ */
9
+ export * from "./config/log";
10
+ export * from "./types";
11
+ export * from "./targets";
12
+ export * from "./variables";
13
+ export * from "./log";
14
+ export * from "./decorators";
package/lib/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- // tslint:disable: ban-types
3
- // tslint:disable: interface-name
4
- // tslint:disable: unified-signatures
5
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
3
  if (k2 === undefined) k2 = k;
7
4
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -9,203 +6,22 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
6
  if (k2 === undefined) k2 = k;
10
7
  o[k2] = m[k];
11
8
  }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __importStar = (this && this.__importStar) || function (mod) {
24
- if (mod && mod.__esModule) return mod;
25
- var result = {};
26
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
- __setModuleDefault(result, mod);
28
- return result;
29
- };
30
- var __metadata = (this && this.__metadata) || function (k, v) {
31
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
32
- };
33
- var __importDefault = (this && this.__importDefault) || function (mod) {
34
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
35
11
  };
36
12
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.SpinaJsDefaultLog = exports.LogModule = exports.ConsoleLogStream = exports.Logger = void 0;
38
- const bunyan = __importStar(require("bunyan"));
39
- const chalk_1 = __importDefault(require("chalk"));
40
- const stream_1 = require("stream");
41
- const configuration_1 = require("@spinajs/configuration");
42
- const di_1 = require("@spinajs/di");
43
- /**
44
- * -----------------------------------------------------------------------------------
45
- * IMPORTANT: log subsystem is havily based on bunyan. It uses bunyan by default, all options & functions are based on
46
- * bunyan lib. However you can implement custom log module and inject it to framework simply by implementing
47
- * `LogModule` that returns custom implementation of `Log` interface. Then override default DI registered class at app bootstrap.
48
- *
49
- * If you simply want to add more places where log goes eg. database, simply add custom log stream to configuration file.
50
- */
51
13
  /**
52
- * Creates child logger
14
+ * We export default configuration for webpack modules
15
+ * Normally we load configuration from disk via filesystem
16
+ * But webpack is bundlig all files into one.
53
17
  *
54
- * @param options - additional logger options
55
- */
56
- function Logger(options) {
57
- return (target, key) => {
58
- let logger;
59
- // property getter
60
- const getter = () => {
61
- if (!logger) {
62
- logger = di_1.DI.get("LogModule").getLogger(options);
63
- }
64
- return logger;
65
- };
66
- // Create new property with getter and setter
67
- Object.defineProperty(target, key, {
68
- get: getter,
69
- enumerable: false,
70
- configurable: false
71
- });
72
- };
73
- }
74
- exports.Logger = Logger;
75
- /**
76
- * Log stream that writes messages in console with proper colours for message types.
77
- * * TRACE - gray
78
- * * DEBUG - white
79
- * * INFO - cyan
80
- * * WARN - yellow
81
- * * ERROR - red
82
- * * FATAL - red on white background
18
+ * When we export, we can see configuration variable
19
+ * in webpack module cache and webpack config loader can see it
83
20
  */
84
- class ConsoleLogStream extends stream_1.Writable {
85
- constructor() {
86
- super(...arguments);
87
- this.TRACE = 10;
88
- this.DEBUG = 20;
89
- this.INFO = 30;
90
- this.WARN = 40;
91
- this.ERROR = 50;
92
- this.FATAL = 60;
93
- }
94
- write(chunk) {
95
- const type = this._getNameFromType(chunk.level);
96
- const err = chunk.err
97
- ? `Exception: ${chunk.err.name}, ${chunk.err.message}, ${chunk.err.stack}`
98
- : "";
99
- const message = `${chunk.time.toISOString()} ${type} ${chunk.name}: ${chunk.msg} (module=${chunk.module}) ${err}`;
100
- let c = null;
101
- switch (chunk.level) {
102
- case this.TRACE:
103
- c = chalk_1.default.gray(message);
104
- break;
105
- case this.DEBUG:
106
- c = chalk_1.default.white(message);
107
- break;
108
- case this.INFO:
109
- c = chalk_1.default.cyan(message);
110
- break;
111
- case this.WARN:
112
- c = chalk_1.default.yellow(message);
113
- break;
114
- case this.ERROR:
115
- c = chalk_1.default.red(message);
116
- break;
117
- case this.FATAL:
118
- c = chalk_1.default.bgRed.white(message);
119
- break;
120
- }
121
- console.log(c);
122
- return true;
123
- }
124
- _getNameFromType(type) {
125
- switch (type) {
126
- case this.TRACE:
127
- return "TRACE";
128
- case this.DEBUG:
129
- return "DEBUG";
130
- case this.INFO:
131
- return "INFO";
132
- case this.WARN:
133
- return "WARN";
134
- case this.ERROR:
135
- return "ERROR";
136
- case this.FATAL:
137
- return "FATAL";
138
- }
139
- }
140
- }
141
- exports.ConsoleLogStream = ConsoleLogStream;
142
- /**
143
- * Default logger options
144
- * used as fallback if no config is provided
145
- */
146
- const DEFAULT_OPTIONS = {
147
- name: "spine-framework",
148
- serializers: bunyan.stdSerializers,
149
- /**
150
- * streams to log to. See more on bunyan docs
151
- */
152
- streams: [
153
- {
154
- type: "raw",
155
- /**
156
- * We use default console log stream with colors
157
- */
158
- stream: new ConsoleLogStream(),
159
- level: process.env.NODE_ENV === "development" ? "trace" : "info"
160
- }
161
- ]
162
- };
163
- /**
164
- * Abstract class to implement for framework log module.
165
- */
166
- class LogModule extends di_1.SyncModule {
167
- }
168
- exports.LogModule = LogModule;
169
- /**
170
- * Default Log implementation that uses bunyan internally. Feel free to implement own
171
- */
172
- let SpinaJsDefaultLog = class SpinaJsDefaultLog extends LogModule {
173
- constructor() {
174
- super(...arguments);
175
- /**
176
- * Injected Configuration object
177
- */
178
- this.cfg = null;
179
- /**
180
- * Name of module
181
- * @access protected
182
- */
183
- this.name = "Log";
184
- }
185
- /**
186
- * Creates child logger
187
- * @param options - additional logger options eg. fields.
188
- */
189
- getLogger(options) {
190
- return this.log.child(options);
191
- }
192
- /**
193
- * Initializes bunyan logger & hooks for process:uncaughtException to log fatal application events
194
- */
195
- resolve() {
196
- // get config
197
- this.log = bunyan.createLogger(this.cfg.get(["log"], DEFAULT_OPTIONS));
198
- process.on("uncaughtException", (err) => {
199
- this.log.fatal(err);
200
- });
201
- }
202
- };
203
- __decorate([
204
- di_1.Autoinject(),
205
- __metadata("design:type", configuration_1.Configuration)
206
- ], SpinaJsDefaultLog.prototype, "cfg", void 0);
207
- SpinaJsDefaultLog = __decorate([
208
- di_1.Injectable(LogModule)
209
- ], SpinaJsDefaultLog);
210
- exports.SpinaJsDefaultLog = SpinaJsDefaultLog;
21
+ __exportStar(require("./config/log"), exports);
22
+ __exportStar(require("./types"), exports);
23
+ __exportStar(require("./targets"), exports);
24
+ __exportStar(require("./variables"), exports);
25
+ __exportStar(require("./log"), exports);
26
+ __exportStar(require("./decorators"), exports);
211
27
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,iCAAiC;AACjC,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErC,+CAAiC;AACjC,kDAA0B;AAC1B,mCAAkC;AAElC,0DAAuD;AACvD,oCAAqE;AAErE;;;;;;;GAOG;AAEH;;;;GAIG;AACH,SAAgB,MAAM,CAAC,OAAa;IAClC,OAAO,CAAC,MAAY,EAAE,GAAY,EAAO,EAAE;QACzC,IAAI,MAAW,CAAC;QAEhB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,OAAE,CAAC,GAAG,CAAY,WAAW,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aAC5D;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,6CAA6C;QAC7C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG,EAAE,MAAM;YACX,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AApBD,wBAoBC;AAED;;;;;;;;GAQG;AACH,MAAa,gBAAiB,SA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AAK,CAAC;IAuBjC,CAAC;IArBC;;;OAGG;IACI,SAAS,CAAC,OAAa;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,aAAa;QACb,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,YAAY,CAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAgB,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CACtD,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAU,EAAE,EAAE;YAC7C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnCC;IADC,eAAU,EAAE;8BACD,6BAAa;8CAAQ;AALtB,iBAAiB;IAD7B,eAAU,CAAC,SAAS,CAAC;GACT,iBAAiB,CAwC7B;AAxCY,8CAAiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,+CAA6B;AAC7B,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,+CAA6B"}
package/lib/log.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ import { IContainer, SyncModule } from "@spinajs/di";
2
+ import { LogTarget } from "./targets/LogTarget";
3
+ import { ICommonTargetOptions, LogLevel, ILogOptions, ILogRule, ILogTargetData, ITargetsOption } from "./types";
4
+ interface ILogTargetDesc {
5
+ instance: LogTarget<ICommonTargetOptions>;
6
+ options?: ITargetsOption;
7
+ rule: ILogRule;
8
+ }
9
+ /**
10
+ * Default log implementation interface. Taken from bunyan. Feel free to implement own.
11
+ */
12
+ export declare class Log extends SyncModule {
13
+ Name: string;
14
+ Variables?: any;
15
+ protected Parent?: Log;
16
+ /**
17
+ * STATIC METHODS FOR LOGGER, ALLOWS TO LOG TO ANY TARGET
18
+ * EVEN BEFORE LOG MODULE INITIALIZATION.
19
+ *
20
+ * Prevents from losing log message when initializing modules
21
+ */
22
+ static Loggers: Map<string, Log>;
23
+ static trace(message: string, name: string, ...args: any[]): void;
24
+ static trace(err: Error, message: string, name: string, ...args: any[]): void;
25
+ static debug(message: string, name: string, ...args: any[]): void;
26
+ static debug(err: Error, message: string, name: string, ...args: any[]): void;
27
+ static info(message: string, name: string, ...args: any[]): void;
28
+ static info(err: Error, message: string, name: string, ...args: any[]): void;
29
+ static warn(message: string, name: string, ...args: any[]): void;
30
+ static warn(err: Error, message: string, name: string, ...args: any[]): void;
31
+ static error(message: string, name: string, ...args: any[]): void;
32
+ static error(err: Error, message: string, name: string, ...args: any[]): void;
33
+ static fatal(message: string, name: string, ...args: any[]): void;
34
+ static fatal(err: Error, message: string, name: string, ...args: any[]): void;
35
+ static security(message: string, name: string, ...args: any[]): void;
36
+ static security(err: Error, message: string, name: string, ...args: any[]): void;
37
+ static success(message: string, name: string, ...args: any[]): void;
38
+ static success(err: Error, message: string, name: string, ...args: any[]): void;
39
+ static clearLoggers(): void;
40
+ protected static LogBuffer: Map<string, ILogTargetData[]>;
41
+ protected static AttachedToExitEvents: boolean;
42
+ protected static write(err: Error | string, message: string | any[], level: LogLevel, name: string, ...args: any[]): void;
43
+ protected Options: ILogOptions;
44
+ protected Rules: ILogRule[];
45
+ protected Targets: ILogTargetDesc[];
46
+ constructor(Name: string, Variables?: any, Parent?: Log);
47
+ resolve(container: IContainer): void;
48
+ trace(message: string, ...args: any[]): void;
49
+ trace(err: Error, message: string, ...args: any[]): void;
50
+ debug(message: string, ...args: any[]): void;
51
+ debug(err: Error, message: string, ...args: any[]): void;
52
+ info(message: string, ...args: any[]): void;
53
+ info(err: Error, message: string, ...args: any[]): void;
54
+ warn(message: string, ...args: any[]): void;
55
+ warn(err: Error, message: string, ...args: any[]): void;
56
+ error(message: string, ...args: any[]): void;
57
+ error(err: Error, message: string, ...args: any[]): void;
58
+ fatal(message: string, ...args: any[]): void;
59
+ fatal(err: Error, message: string, ...args: any[]): void;
60
+ security(message: string, ...args: any[]): void;
61
+ security(err: Error, message: string, ...args: any[]): void;
62
+ success(message: string, ...args: any[]): void;
63
+ success(err: Error, message: string, ...args: any[]): void;
64
+ child(name: string, variables?: {}): Log;
65
+ protected writeBufferedMessages(): void;
66
+ protected resolveLogTargets(): void;
67
+ protected matchRulesToLogger(): void;
68
+ protected write(err: Error | string, message: string | any[], level: LogLevel, ...args: any[]): void;
69
+ }
70
+ export {};