-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #720 from DustinCampbell/omnisharp-logging
Improve OmniSharp server logging
- Loading branch information
Showing
5 changed files
with
114 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
export class Logger { | ||
private _writer: (message: string) => void; | ||
private _prefix: string; | ||
|
||
private _indentLevel: number = 0; | ||
private _indentSize: number = 4; | ||
private _atLineStart: boolean = false; | ||
|
||
constructor(writer: (message: string) => void, prefix?: string) { | ||
this._writer = writer; | ||
this._prefix = prefix; | ||
} | ||
|
||
private _appendCore(message: string): void { | ||
if (this._atLineStart) { | ||
if (this._indentLevel > 0) { | ||
const indent = " ".repeat(this._indentLevel * this._indentSize); | ||
this._writer(indent); | ||
} | ||
|
||
if (this._prefix) { | ||
this._writer(`[${this._prefix}] `); | ||
} | ||
|
||
this._atLineStart = false; | ||
} | ||
|
||
this._writer(message); | ||
} | ||
|
||
public increaseIndent(): void { | ||
this._indentLevel += 1; | ||
} | ||
|
||
public decreaseIndent(): void { | ||
if (this._indentLevel > 0) { | ||
this._indentLevel -= 1; | ||
} | ||
} | ||
|
||
public append(message?: string): void { | ||
message = message || ""; | ||
this._appendCore(message); | ||
} | ||
|
||
public appendLine(message?: string): void { | ||
message = message || ""; | ||
this._appendCore(message + '\n'); | ||
this._atLineStart = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters