| @@ -14,12 +14,12 export class Registry { | |||||
| 14 |
|
14 | |||
| 15 | if (this._registry[id]) |
|
15 | if (this._registry[id]) | |
| 16 | return this._registry[id]; |
|
16 | return this._registry[id]; | |
|
|
17 | else | |||
|
|
18 | throw new Error("The specified trace source doesn't exists"); | |||
|
|
19 | } | |||
| 17 |
|
20 | |||
| 18 | const source = new TraceSource(id); |
|
21 | has(id: string) { | |
| 19 |
this._registry[id] |
|
22 | return !!this._registry[id]; | |
| 20 | this._onNewSource(source); |
|
|||
| 21 |
|
||||
| 22 | return source; |
|
|||
| 23 | } |
|
23 | } | |
| 24 |
|
24 | |||
| 25 | add(id: any, source: TraceSource) { |
|
25 | add(id: any, source: TraceSource) { | |
| @@ -136,6 +136,12 export class TraceSource { | |||||
| 136 | * @param id the id for the trace source |
|
136 | * @param id the id for the trace source | |
| 137 | */ |
|
137 | */ | |
| 138 | static get(id: any) { |
|
138 | static get(id: any) { | |
| 139 |
|
|
139 | if (!Registry.instance.has(id)) { | |
|
|
140 | const trace = new TraceSource(id); | |||
|
|
141 | Registry.instance.add(id, trace); | |||
|
|
142 | return trace; | |||
|
|
143 | } else { | |||
|
|
144 | return Registry.instance.get(id); | |||
|
|
145 | } | |||
| 140 | } |
|
146 | } | |
| 141 | } |
|
147 | } | |
General Comments 0
You need to be logged in to leave comments.
Login now
