##// END OF EJS Templates
minor fixes
cin -
r45:3c6524f04866 di-typescript
parent child
Show More
@@ -77,9 +77,10
77 77 "dev": true
78 78 },
79 79 "dojo": {
80 "version": "1.13.0",
81 "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.13.0.tgz",
82 "integrity": "sha512-mGoGvsXAbPkUrBnxCoO7m6CFH8jvWq7rAL7fP7jrhJEOyswA/bZwWdXwEH0ovs68t8S0+xOpV/3V7addYbaiAA=="
80 "version": "1.14.2",
81 "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz",
82 "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==",
83 "dev": true
83 84 },
84 85 "duplexer": {
85 86 "version": "0.1.1",
@@ -16,7 +16,7
16 16 "publishConfig": {
17 17 "access": "public"
18 18 },
19 "dependencies": {
19 "peerDependencies": {
20 20 "dojo": "^1.10.0"
21 21 },
22 22 "devDependencies": {
@@ -24,7 +24,8
24 24 "tape": "latest",
25 25 "@types/tape": "latest",
26 26 "requirejs": "latest",
27 "faucet": "latest"
27 "faucet": "latest",
28 "dojo": "^1.10.0"
28 29 },
29 30 "types": "main.d.ts"
30 31 }
@@ -1,12 +1,13
1 1 import { IObservable, IDestroyable, ICancellation } from "../../interfaces";
2 import { TraceEvent, LogLevel, WarnLevel, DebugLevel } from "../TraceSource";
2 3 import { Cancellation } from "../../Cancellation";
3 import { TraceEvent, LogLevel, WarnLevel } from "../TraceSource";
4 import { destroy } from "../../safe";
4 5
5 6 export class ConsoleWriter implements IDestroyable {
6 7 readonly _subscriptions = new Array<IDestroyable>();
7 8
8 9 writeEvents(source: IObservable<TraceEvent>, ct: ICancellation = Cancellation.none) {
9 var subscription = source.on(this.writeEvent.bind(this));
10 const subscription = source.on(this.writeEvent.bind(this));
10 11 if (ct.isSupported()) {
11 12 ct.register(subscription.destroy.bind(subscription));
12 13 }
@@ -14,16 +15,22 export class ConsoleWriter implements ID
14 15 }
15 16
16 17 writeEvent(next: TraceEvent) {
17 if (next.level >= LogLevel) {
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 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 26 console.warn(next.source.id.toString(), next.arg);
21 27 } else {
28 // tslint:disable-next-line
22 29 console.error(next.source.id.toString(), next.arg);
23 30 }
24 31 }
25 32
26 33 destroy() {
27 this._subscriptions.forEach(x => x.destroy());
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