Tweak indent string generation slightly to make greggm smile
This commit is contained in:
Родитель
833ea9f5d8
Коммит
bac456cbbb
|
@ -9,8 +9,8 @@ export class Logger {
|
||||||
private _writer: (message: string) => void;
|
private _writer: (message: string) => void;
|
||||||
private _prefix: string;
|
private _prefix: string;
|
||||||
|
|
||||||
private _indent: string = ' ';
|
|
||||||
private _indentLevel: number = 0;
|
private _indentLevel: number = 0;
|
||||||
|
private _indentSize: number = 4;
|
||||||
private _atLineStart: boolean = false;
|
private _atLineStart: boolean = false;
|
||||||
|
|
||||||
constructor(writer: (message: string) => void, prefix?: string) {
|
constructor(writer: (message: string) => void, prefix?: string) {
|
||||||
|
@ -21,8 +21,7 @@ export class Logger {
|
||||||
private _appendCore(message: string): void {
|
private _appendCore(message: string): void {
|
||||||
if (this._atLineStart) {
|
if (this._atLineStart) {
|
||||||
if (this._indentLevel > 0) {
|
if (this._indentLevel > 0) {
|
||||||
const repeatCount = this._indentLevel;
|
const indent = " ".repeat(this._indentLevel * this._indentSize);
|
||||||
const indent = this._indent.repeat(repeatCount);
|
|
||||||
this._writer(indent);
|
this._writer(indent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче