Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Introduce proton logger #570

Merged
merged 2 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Contains common infrastructure for CLIs - mainly AppBuilder and NativeScript.
Installation
===

Latest version: 0.0.5
Latest version: 0.1.3

Release date: 2015, November 3
Release date: 2015, December 15

### System Requirements

Expand Down
1 change: 1 addition & 0 deletions appbuilder/proton-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"use strict";

require("../bootstrap");
$injector.require("logger", "./appbuilder/proton-logger");

import {OptionsBase} from "../options";
$injector.require("staticConfig", "./appbuilder/proton-static-config");
Expand Down
86 changes: 86 additions & 0 deletions appbuilder/proton-logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
///<reference path="../.d.ts"/>
"use strict";

import * as stream from "stream";
import Future = require("fibers/future");

export class ProtonLogger implements ILogger {
setLevel(level: string): void {
/* left for future implementation */
}

getLevel(): string {
/* improve future implementation */
return "INFO";
}

fatal(...args: string[]): void {
/* left for future implementation */
}

error(...args: string[]): void {
/* left for future implementation */
}

warn(...args: string[]): void {
/* left for future implementation */
}

warnWithLabel(...args: string[]): void {
/* left for future implementation */
}

info(...args: string[]): void {
/* left for future implementation */
}

debug(...args: string[]): void {
/* left for future implementation */
}

trace(...args: string[]): void {
/* left for future implementation */
}

out(...args: string[]): void {
/* left for future implementation */
}

write(...args: string[]): void {
/* left for future implementation */
}

prepare(item: any): string {
if (typeof item === "undefined" || item === null) {
return "[no content]";
}
if (typeof item === "string") {
return item;
}
// do not try to read streams, because they may not be rewindable
if (item instanceof stream.Readable) {
return "[ReadableStream]";
}

return JSON.stringify(item);
}

public printInfoMessageOnSameLine(message: string): void {
/* left for future implementation */
}

public printMsgWithTimeout(message: string, timeout: number): IFuture <void> {
let printMsgFuture = new Future<void>();
setTimeout(() => {
this.printInfoMessageOnSameLine(message);
printMsgFuture.return();
}, timeout);

return printMsgFuture;
}

public printMarkdown(...args: string[]): void {
/* left for future implementation */
}
}
$injector.register("logger", ProtonLogger);
1 change: 0 additions & 1 deletion bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if (!global.Promise) {
require("colors");
$injector.require("errors", "./errors");
$injector.requirePublic("fs", "./file-system");
$injector.require("logger", "./logger");
$injector.require("sysInfoBase", "./sys-info-base");
$injector.require("hostInfo", "./host-info");

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mobile-cli-lib",
"preferGlobal": false,
"version": "0.1.2",
"version": "0.1.3",
"author": "Telerik <[email protected]>",
"description": "common lib used by different CLI",
"bin": {
Expand Down