microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
445b113fa38f291ca910604a6a87bab6cb5f95e9

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/outputChannelLogger.ts

41lines · 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/**
5 * Formatter for the Output channel.
6 */
7
8import {ILogger} from "../common/log/loggers";
9import {LogHelper, LogLevel} from "../common/log/logHelper";
10import {OutputChannel} from "vscode";
11
12export class OutputChannelLogger implements ILogger {
13 private outputChannel: OutputChannel;
14
15 constructor(outputChannel: OutputChannel) {
16 this.outputChannel = outputChannel;
17 }
18
19 public logInternalMessage(logLevel: LogLevel, message: string) {
20 console.log(this.getFormattedInternalMessage(logLevel, message));
21 }
22
23 public logMessage(message: string, formatMessage: boolean = true ) {
24 this.outputChannel.appendLine(formatMessage ?
25 this.getFormattedMessage(message) :
26 message);
27 this.outputChannel.show();
28 }
29
30 public logError(errorMessage: string, error?: any, logStack: boolean = true) {
31 this.logMessage(errorMessage, /* formatMessage */ false);
32 }
33
34 private getFormattedMessage(message: string) {
35 return `######### ${message} ##########`;
36 }
37
38 private getFormattedInternalMessage(logLevel: LogLevel, message: string) {
39 return (`${LogHelper.INTERNAL_TAG} [${LogLevel[logLevel]}] ${message}`);
40 }
41}