| @@ -77,9 +77,10 | |||||
| 77 | "dev": true |
|
77 | "dev": true | |
| 78 | }, |
|
78 | }, | |
| 79 | "dojo": { |
|
79 | "dojo": { | |
| 80 |
"version": "1.1 |
|
80 | "version": "1.14.2", | |
| 81 |
"resolved": "https://registry.npmjs.org/dojo/-/dojo-1.1 |
|
81 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz", | |
| 82 | "integrity": "sha512-mGoGvsXAbPkUrBnxCoO7m6CFH8jvWq7rAL7fP7jrhJEOyswA/bZwWdXwEH0ovs68t8S0+xOpV/3V7addYbaiAA==" |
|
82 | "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==", | |
|
|
83 | "dev": true | |||
| 83 | }, |
|
84 | }, | |
| 84 | "duplexer": { |
|
85 | "duplexer": { | |
| 85 | "version": "0.1.1", |
|
86 | "version": "0.1.1", | |
| @@ -16,7 +16,7 | |||||
| 16 | "publishConfig": { |
|
16 | "publishConfig": { | |
| 17 | "access": "public" |
|
17 | "access": "public" | |
| 18 | }, |
|
18 | }, | |
| 19 |
" |
|
19 | "peerDependencies": { | |
| 20 | "dojo": "^1.10.0" |
|
20 | "dojo": "^1.10.0" | |
| 21 | }, |
|
21 | }, | |
| 22 | "devDependencies": { |
|
22 | "devDependencies": { | |
| @@ -24,7 +24,8 | |||||
| 24 | "tape": "latest", |
|
24 | "tape": "latest", | |
| 25 | "@types/tape": "latest", |
|
25 | "@types/tape": "latest", | |
| 26 | "requirejs": "latest", |
|
26 | "requirejs": "latest", | |
| 27 | "faucet": "latest" |
|
27 | "faucet": "latest", | |
|
|
28 | "dojo": "^1.10.0" | |||
| 28 | }, |
|
29 | }, | |
| 29 | "types": "main.d.ts" |
|
30 | "types": "main.d.ts" | |
| 30 | } |
|
31 | } | |
| @@ -1,12 +1,13 | |||||
| 1 | import { IObservable, IDestroyable, ICancellation } from "../../interfaces"; |
|
1 | import { IObservable, IDestroyable, ICancellation } from "../../interfaces"; | |
|
|
2 | import { TraceEvent, LogLevel, WarnLevel, DebugLevel } from "../TraceSource"; | |||
| 2 | import { Cancellation } from "../../Cancellation"; |
|
3 | import { Cancellation } from "../../Cancellation"; | |
| 3 | import { TraceEvent, LogLevel, WarnLevel } from "../TraceSource"; |
|
4 | import { destroy } from "../../safe"; | |
| 4 |
|
5 | |||
| 5 | export class ConsoleWriter implements IDestroyable { |
|
6 | export class ConsoleWriter implements IDestroyable { | |
| 6 | readonly _subscriptions = new Array<IDestroyable>(); |
|
7 | readonly _subscriptions = new Array<IDestroyable>(); | |
| 7 |
|
8 | |||
| 8 | writeEvents(source: IObservable<TraceEvent>, ct: ICancellation = Cancellation.none) { |
|
9 | writeEvents(source: IObservable<TraceEvent>, ct: ICancellation = Cancellation.none) { | |
| 9 |
|
|
10 | const subscription = source.on(this.writeEvent.bind(this)); | |
| 10 | if (ct.isSupported()) { |
|
11 | if (ct.isSupported()) { | |
| 11 | ct.register(subscription.destroy.bind(subscription)); |
|
12 | ct.register(subscription.destroy.bind(subscription)); | |
| 12 | } |
|
13 | } | |
| @@ -14,16 +15,22 export class ConsoleWriter implements ID | |||||
| 14 | } |
|
15 | } | |
| 15 |
|
16 | |||
| 16 | writeEvent(next: TraceEvent) { |
|
17 | writeEvent(next: TraceEvent) { | |
| 17 |
if (next.level >= |
|
18 | if (next.level >= DebugLevel) { | |
|
|
19 | // tslint:disable-next-line | |||
|
|
20 | console.debug(next.source.id.toString(), next.arg); | |||
|
|
21 | } else if (next.level >= LogLevel) { | |||
|
|
22 | // tslint:disable-next-line | |||
| 18 | console.log(next.source.id.toString(), next.arg); |
|
23 | console.log(next.source.id.toString(), next.arg); | |
| 19 | } else if(next.level >= WarnLevel) { |
|
24 | } else if (next.level >= WarnLevel) { | |
|
|
25 | // tslint:disable-next-line | |||
| 20 | console.warn(next.source.id.toString(), next.arg); |
|
26 | console.warn(next.source.id.toString(), next.arg); | |
| 21 | } else { |
|
27 | } else { | |
|
|
28 | // tslint:disable-next-line | |||
| 22 | console.error(next.source.id.toString(), next.arg); |
|
29 | console.error(next.source.id.toString(), next.arg); | |
| 23 | } |
|
30 | } | |
| 24 | } |
|
31 | } | |
| 25 |
|
32 | |||
| 26 | destroy() { |
|
33 | destroy() { | |
| 27 |
this._subscriptions.forEach( |
|
34 | this._subscriptions.forEach(destroy); | |
| 28 | } |
|
35 | } | |
| 29 | } No newline at end of file |
|
36 | } | |
General Comments 0
You need to be logged in to leave comments.
Login now
