Skip to content

Commit 5678da7

Browse files
author
Dimitar Tachev
authored
Merge pull request #4489 from NativeScript/tachev/update-log4js
chore: update log4js to its latest version
2 parents a6b20b5 + da783c7 commit 5678da7

File tree

13 files changed

+182
-145
lines changed

13 files changed

+182
-145
lines changed

config/config.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"DEBUG": false,
33
"TYPESCRIPT_COMPILER_OPTIONS": {},
4-
"CI_LOGGER": false,
54
"ANDROID_DEBUG_UI_MAC": "Google Chrome",
65
"USE_POD_SANDBOX": false,
76
"DISABLE_HOOKS": false,
87
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files",
98
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s",
109
"PREVIEW_APP_ENVIRONMENT": "live",
1110
"GA_TRACKING_ID": "UA-111455-51"
12-
}
11+
}

lib/android-tools-info.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3333
private $fs: IFileSystem,
3434
private $logger: ILogger,
3535
private $options: IOptions,
36-
protected $staticConfig: Config.IStaticConfig) { }
36+
protected $staticConfig: Config.IStaticConfig) {
37+
}
3738

3839
@cache()
3940
public getToolsInfo(): IAndroidToolsInfoData {

lib/common/commands/device/list-devices.ts

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class ListDevicesCommand implements ICommand {
3030
const table: any = createTable(["#", "Device Name", "Platform", "Device Identifier", "Type", "Status"], []);
3131
let action: (_device: Mobile.IDevice) => Promise<void>;
3232
if (this.$options.json) {
33-
this.$logger.setLevel("ERROR");
3433
action = async (device) => {
3534
this.$logger.out(JSON.stringify(device.deviceInfo));
3635
};

lib/common/definitions/config.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ declare module Config {
2828

2929
interface IConfig {
3030
DEBUG?: boolean;
31-
CI_LOGGER?: boolean;
3231
DISABLE_HOOKS: boolean;
3332
}
3433
}

lib/common/definitions/log4js.d.ts

-47
This file was deleted.

lib/common/definitions/logger.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
interface ILogger {
2-
setLevel(level: string): void;
32
getLevel(): string;
43
fatal(formatStr?: any, ...args: any[]): void;
54
error(formatStr?: any, ...args: any[]): void;

lib/common/logger.ts

+20-21
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,36 @@ const TerminalRenderer = require("marked-terminal");
66
const chalk = require("chalk");
77

88
export class Logger implements ILogger {
9-
private log4jsLogger: log4js.ILogger = null;
9+
private log4jsLogger: log4js.Logger = null;
1010
private passwordRegex = /(password=).*?(['&,]|$)|(password["']?\s*:\s*["']).*?(["'])/i;
1111
private passwordReplacement = "$1$3*******$2$4";
1212
private static LABEL = "[WARNING]:";
1313

1414
constructor($config: Config.IConfig,
1515
private $options: IOptions) {
16-
const appenders: log4js.IAppender[] = [];
17-
18-
if (!$config.CI_LOGGER) {
19-
appenders.push({
20-
type: "console",
21-
layout: {
22-
type: "messagePassThrough"
23-
}
24-
});
25-
}
26-
27-
log4js.configure({ appenders: appenders });
28-
29-
this.log4jsLogger = log4js.getLogger();
30-
16+
const appenders: IDictionary<log4js.Appender> = {};
17+
const categories: IDictionary<{ appenders: string[]; level: string; }> = {};
18+
let level: string = null;
3119
if (this.$options.log) {
32-
this.log4jsLogger.setLevel(this.$options.log);
20+
level = this.$options.log;
3321
} else {
34-
this.log4jsLogger.setLevel($config.DEBUG ? "TRACE" : "INFO");
22+
level = $config.DEBUG ? "TRACE" : "INFO";
3523
}
36-
}
3724

38-
setLevel(level: string): void {
39-
this.log4jsLogger.setLevel(level);
25+
appenders["out"] = {
26+
type: "console",
27+
layout: {
28+
type: "messagePassThrough"
29+
}
30+
};
31+
categories["default"] = {
32+
appenders: ['out'],
33+
level
34+
};
35+
36+
log4js.configure({ appenders, categories });
37+
38+
this.log4jsLogger = log4js.getLogger();
4039
}
4140

4241
getLevel(): string {

lib/common/test/unit-tests/stubs.ts

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class LockServiceStub implements ILockService {
1818
}
1919

2020
export class CommonLoggerStub implements ILogger {
21-
setLevel(level: string): void { }
2221
getLevel(): string { return undefined; }
2322
fatal(...args: string[]): void { }
2423
error(...args: string[]): void { }
@@ -175,7 +174,6 @@ export class DeviceLogProviderStub extends EventEmitter implements Mobile.IDevic
175174
}
176175

177176
setLogLevel(level: string, deviceIdentifier?: string): void {
178-
this.logger.setLevel(level);
179177
}
180178

181179
setApplicationPidForDevice(deviceIdentifier: string, pid: string): void {

lib/config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as shelljs from "shelljs";
33
import * as os from "os";
44

55
export class Configuration implements IConfiguration { // User specific config
6-
CI_LOGGER = false;
76
DEBUG = false;
87
ANDROID_DEBUG_UI: string = null;
98
USE_POD_SANDBOX: boolean = false;

npm-shrinkwrap.json

+95-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"istextorbinary": "2.2.1",
5151
"jimp": "0.2.28",
5252
"lodash": "4.17.11",
53-
"log4js": "1.0.1",
53+
"log4js": "4.1.0",
5454
"marked": "0.5.1",
5555
"marked-terminal": "3.1.1",
5656
"minimatch": "3.0.2",

0 commit comments

Comments
 (0)