microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/extension/android/logCatMonitorManager.ts
29lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import { LogCatMonitor } from "./logCatMonitor"; |
| 5 | |
| 6 | export class LogCatMonitorManager { |
| 7 | public static readonly logCatMonitorsCache: { [key: string]: LogCatMonitor } = {}; |
| 8 | |
| 9 | public static addMonitor(monitor: LogCatMonitor): void { |
| 10 | this.logCatMonitorsCache[monitor.deviceId.toLowerCase()] = monitor; |
| 11 | } |
| 12 | |
| 13 | public static getMonitor(deviceId: string): LogCatMonitor { |
| 14 | return this.logCatMonitorsCache[deviceId.toLowerCase()]; |
| 15 | } |
| 16 | |
| 17 | public static delMonitor(deviceId: string): void { |
| 18 | if (this.logCatMonitorsCache[deviceId.toLowerCase()]) { |
| 19 | this.logCatMonitorsCache[deviceId.toLowerCase()].dispose(); |
| 20 | delete this.logCatMonitorsCache[deviceId.toLowerCase()]; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public static cleanUp(): void { |
| 25 | Object.keys(LogCatMonitorManager.logCatMonitorsCache).forEach(monitor => { |
| 26 | LogCatMonitorManager.delMonitor(monitor); |
| 27 | }); |
| 28 | } |
| 29 | } |
| 30 | |