Skip to content

Commit e874d33

Browse files
chore: handle changes in logger API
There are several changes in logger API that need to be changed in the code - they are mostly renaming of methods.
1 parent b28f5be commit e874d33

40 files changed

+101
-100
lines changed

lib/commands/appstore-list.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export class ListiOSApps implements ICommand {
3434
const applications = await this.$applePortalApplicationService.getApplications({ username, password });
3535

3636
if (!applications || !applications.length) {
37-
this.$logger.out("Seems you don't have any applications yet.");
37+
this.$logger.info("Seems you don't have any applications yet.");
3838
} else {
3939
const table: any = createTable(["Application Name", "Bundle Identifier", "In Flight Version"], applications.map(application => {
4040
const version = (application && application.versionSets && application.versionSets.length && application.versionSets[0].inFlightVersion && application.versionSets[0].inFlightVersion.version) || "";
4141
return [application.name, application.bundleId, version];
4242
}));
4343

44-
this.$logger.out(table.toString());
44+
this.$logger.info(table.toString());
4545
}
4646
}
4747
}

lib/commands/extensibility/list-extensions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ListExtensionsCommand implements ICommand {
1313
});
1414

1515
const table = helpers.createTable(["Name", "Version"], data);
16-
this.$logger.out(table.toString());
16+
this.$logger.info(table.toString());
1717
} else {
1818
this.$logger.info("No extensions installed.");
1919
}

lib/commands/list-platforms.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ export class ListPlatformsCommand implements ICommand {
1515
if (installedPlatforms.length > 0) {
1616
const preparedPlatforms = this.$platformService.getPreparedPlatforms(this.$projectData);
1717
if (preparedPlatforms.length > 0) {
18-
this.$logger.out("The project is prepared for: ", helpers.formatListOfNames(preparedPlatforms, "and"));
18+
this.$logger.info("The project is prepared for: ", helpers.formatListOfNames(preparedPlatforms, "and"));
1919
} else {
20-
this.$logger.out("The project is not prepared for any platform");
20+
this.$logger.info("The project is not prepared for any platform");
2121
}
2222

23-
this.$logger.out("Installed platforms: ", helpers.formatListOfNames(installedPlatforms, "and"));
23+
this.$logger.info("Installed platforms: ", helpers.formatListOfNames(installedPlatforms, "and"));
2424
} else {
2525
const formattedPlatformsList = helpers.formatListOfNames(this.$platformService.getAvailablePlatforms(this.$projectData), "and");
26-
this.$logger.out("Available platforms for this OS: ", formattedPlatformsList);
27-
this.$logger.out("No installed platforms found. Use $ tns platform add");
26+
this.$logger.info("Available platforms for this OS: ", formattedPlatformsList);
27+
this.$logger.info("No installed platforms found. Use $ tns platform add");
2828
}
2929
}
3030
}

lib/commands/plugin/list-plugins.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ export class ListPluginsCommand implements ICommand {
1616
const dependenciesData: string[][] = this.createTableCells(installedPlugins.dependencies);
1717

1818
const dependenciesTable: any = createTable(headers, dependenciesData);
19-
this.$logger.out("Dependencies:");
20-
this.$logger.out(dependenciesTable.toString());
19+
this.$logger.info("Dependencies:");
20+
this.$logger.info(dependenciesTable.toString());
2121

2222
if (installedPlugins.devDependencies && installedPlugins.devDependencies.length) {
2323
const devDependenciesData: string[][] = this.createTableCells(installedPlugins.devDependencies);
2424

2525
const devDependenciesTable: any = createTable(headers, devDependenciesData);
2626

27-
this.$logger.out("Dev Dependencies:");
28-
this.$logger.out(devDependenciesTable.toString());
27+
this.$logger.info("Dev Dependencies:");
28+
this.$logger.info(devDependenciesTable.toString());
2929
} else {
30-
this.$logger.out("There are no dev dependencies.");
30+
this.$logger.info("There are no dev dependencies.");
3131
}
3232

3333
const viewDependenciesCommand: string = "npm view <pluginName> grep dependencies".cyan.toString();

lib/commands/post-install.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class PostInstallCliCommand implements ICommand {
3838
}
3939

4040
// Make sure the success message is separated with at least one line from all other messages.
41-
this.$logger.out();
41+
this.$logger.info();
4242
this.$logger.printMarkdown("Installation successful. You are good to go. Connect with us on `http://twitter.com/NativeScript`.");
4343

4444
if (canExecutePostInstallTask) {

lib/common/commands/analytics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AnalyticsCommand implements ICommand {
4141
break;
4242
case "status":
4343
case "":
44-
this.$logger.out(await this.$analyticsService.getStatusMessage(this.settingName, this.$options.json, this.humanReadableSettingName));
44+
this.$logger.info(await this.$analyticsService.getStatusMessage(this.settingName, this.$options.json, this.humanReadableSettingName));
4545
break;
4646
}
4747
}

lib/common/commands/autocompletion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AutoCompleteCommand implements ICommand {
1919
this.$logger.info("Autocompletion is already enabled");
2020
}
2121
} else {
22-
this.$logger.out("If you are using bash or zsh, you can enable command-line completion.");
22+
this.$logger.info("If you are using bash or zsh, you can enable command-line completion.");
2323
const message = "Do you want to enable it now?";
2424

2525
const autoCompetionStatus = await this.$prompter.confirm(message, () => true);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ListApplicationsCommand implements ICommand {
1919
};
2020
await this.$devicesService.execute(action);
2121

22-
this.$logger.out(output.join(EOL));
22+
this.$logger.info(output.join(EOL));
2323
}
2424
}
2525
$injector.registerCommand(["device|list-applications", "devices|list-applications"], ListApplicationsCommand);

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export class ListDevicesCommand implements ICommand {
2323
this.printEmulators("\nAvailable emulators", emulators);
2424
}
2525

26-
this.$logger.out("\nConnected devices & emulators");
26+
this.$logger.info("\nConnected devices & emulators");
2727
let index = 1;
2828
await this.$devicesService.initialize({ platform: args[0], deviceId: null, skipInferPlatform: true, skipDeviceDetectionInterval: true, skipEmulatorStart: true });
2929

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) {
3333
action = async (device) => {
34-
this.$logger.out(JSON.stringify(device.deviceInfo));
34+
this.$logger.info(JSON.stringify(device.deviceInfo));
3535
};
3636
} else {
3737
action = async (device) => {
@@ -44,18 +44,18 @@ export class ListDevicesCommand implements ICommand {
4444
await this.$devicesService.execute(action, undefined, { allowNoDevices: true });
4545

4646
if (!this.$options.json && table.length) {
47-
this.$logger.out(table.toString());
47+
this.$logger.info(table.toString());
4848
}
4949
}
5050

5151
private printEmulators(title: string, emulators: Mobile.IDeviceInfo[]) {
52-
this.$logger.out(title);
52+
this.$logger.info(title);
5353
const table: any = createTable(["Device Name", "Platform", "Version", "Device Identifier", "Image Identifier", "Error Help"], []);
5454
for (const info of emulators) {
5555
table.push([info.displayName, info.platform, info.version, info.identifier || "", info.imageIdentifier || "", info.errorHelp || ""]);
5656
}
5757

58-
this.$logger.out(table.toString());
58+
this.$logger.info(table.toString());
5959
}
6060
}
6161

lib/common/commands/proxy/proxy-clear.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ProxyClearCommand extends ProxyCommandBase {
1010

1111
public async execute(args: string[]): Promise<void> {
1212
await this.$proxyService.clearCache();
13-
this.$logger.out("Successfully cleared proxy.");
13+
this.$logger.info("Successfully cleared proxy.");
1414
await this.tryTrackUsage();
1515
}
1616
}

lib/common/commands/proxy/proxy-get.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ProxyGetCommand extends ProxyCommandBase {
1010
}
1111

1212
public async execute(args: string[]): Promise<void> {
13-
this.$logger.out(await this.$proxyService.getInfo());
13+
this.$logger.info(await this.$proxyService.getInfo());
1414
await this.tryTrackUsage();
1515
}
1616
}

lib/common/commands/proxy/proxy-set.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export class ProxySetCommand extends ProxyCommandBase {
107107
this.$logger.warn(`${messageNote}Run '${clientName} proxy set --help' for more information.`);
108108

109109
await this.$proxyService.setCache(settings);
110-
this.$logger.out(`Successfully setup proxy.${EOL}`);
111-
this.$logger.out(await this.$proxyService.getInfo());
110+
this.$logger.info(`Successfully setup proxy.${EOL}`);
111+
this.$logger.info(await this.$proxyService.getInfo());
112112
await this.tryTrackUsage();
113113
}
114114

lib/common/dispatchers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class CommandDispatcher implements ICommandDispatcher {
6161
if (json && json.buildVersion) {
6262
version = `${version}-${json.buildVersion}`;
6363
}
64-
this.$logger.out(version);
64+
this.$logger.info(version);
6565
}
6666
}
6767
$injector.register("commandDispatcher", CommandDispatcher);

lib/common/logger/appenders/emit-appender.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { LoggingEvent } from "log4js";
22
import { EventEmitter } from "events";
3-
import { EmitAppenderEventName } from "../../../constants";
3+
import { EMIT_APPENDER_EVENT_NAME } from "../../../constants";
44

55
function emitAppender(layout: Function, emitter: EventEmitter) {
66
const appender = (loggingEvent: LoggingEvent) => {
7-
emitter.emit(EmitAppenderEventName, { loggingEvent, formattedMessage: layout(loggingEvent) });
7+
emitter.emit(EMIT_APPENDER_EVENT_NAME, { loggingEvent, formattedMessage: layout(loggingEvent) });
88
};
99

1010
appender.shutdown = () => {
11-
emitter.removeAllListeners(EmitAppenderEventName);
11+
emitter.removeAllListeners(EMIT_APPENDER_EVENT_NAME);
1212
};
1313

1414
return appender;

lib/common/mobile/android/android-emulator-services.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { AndroidVirtualDevice } from "../../constants";
22
import { getCurrentEpochTime, sleep } from "../../helpers";
33
import { EOL } from "os";
4+
import { LoggerConfigData } from "../../../constants";
45

56
export class AndroidEmulatorServices implements Mobile.IEmulatorPlatformService {
67
constructor(private $androidGenymotionService: Mobile.IAndroidVirtualDeviceService,
@@ -65,7 +66,7 @@ export class AndroidEmulatorServices implements Mobile.IEmulatorPlatformService
6566
this.$androidVirtualDeviceService.detach(deviceInfo);
6667
}
6768

68-
private async startEmulatorCore(options: Mobile.IAndroidStartEmulatorOptions): Promise<{runningEmulator: Mobile.IDeviceInfo, errors: string[], endTimeEpoch: number}> {
69+
private async startEmulatorCore(options: Mobile.IAndroidStartEmulatorOptions): Promise<{ runningEmulator: Mobile.IDeviceInfo, errors: string[], endTimeEpoch: number }> {
6970
const timeout = options.timeout || AndroidVirtualDevice.TIMEOUT_SECONDS;
7071
const endTimeEpoch = getCurrentEpochTime() + this.$utils.getMilliSecondsTimeout(timeout);
7172

@@ -146,21 +147,21 @@ export class AndroidEmulatorServices implements Mobile.IEmulatorPlatformService
146147
return (best && best.version >= AndroidVirtualDevice.MIN_ANDROID_VERSION) ? best : null;
147148
}
148149

149-
private async waitForEmulatorBootToComplete(emulator: Mobile.IDeviceInfo, endTimeEpoch: number, timeout: number): Promise<{runningEmulator: Mobile.IDeviceInfo, errors: string[]}> {
150-
this.$logger.printInfoMessageOnSameLine("Waiting for emulator device initialization...");
150+
private async waitForEmulatorBootToComplete(emulator: Mobile.IDeviceInfo, endTimeEpoch: number, timeout: number): Promise<{ runningEmulator: Mobile.IDeviceInfo, errors: string[] }> {
151+
this.$logger.info("Waiting for emulator device initialization...", { [LoggerConfigData.skipNewLine]: true });
151152

152153
const isInfiniteWait = this.$utils.getMilliSecondsTimeout(timeout || AndroidVirtualDevice.TIMEOUT_SECONDS) === 0;
153154
while (getCurrentEpochTime() < endTimeEpoch || isInfiniteWait) {
154155
const isEmulatorBootCompleted = await this.isEmulatorBootCompleted(emulator.identifier);
155156
if (isEmulatorBootCompleted) {
156-
this.$logger.printInfoMessageOnSameLine(EOL);
157+
this.$logger.info(EOL, { [LoggerConfigData.skipNewLine]: true });
157158
return {
158159
runningEmulator: emulator,
159160
errors: []
160161
};
161162
}
162163

163-
this.$logger.printInfoMessageOnSameLine(".");
164+
this.$logger.info(".", { [LoggerConfigData.skipNewLine]: true });
164165
await sleep(10000);
165166
}
166167

lib/common/mobile/device-log-provider.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DeviceLogProviderBase } from "./device-log-provider-base";
22
import { DEVICE_LOG_EVENT_NAME } from "../constants";
3+
import { LoggerConfigData } from "../../constants";
34

45
export class DeviceLogProvider extends DeviceLogProviderBase {
56
constructor(protected $logFilter: Mobile.ILogFilter,
@@ -21,7 +22,7 @@ export class DeviceLogProvider extends DeviceLogProviderBase {
2122
}
2223

2324
private logDataCore(data: string): void {
24-
this.$logger.write(data);
25+
this.$logger.info(data, { [LoggerConfigData.skipNewLine]: true });
2526
}
2627
}
2728
$injector.register("deviceLogProvider", DeviceLogProvider);

lib/common/mobile/ios/device/ios-device-file-system.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
1919
let children: string[] = [];
2020
const result = await this.$iosDeviceOperations.listDirectory([{ deviceId: deviceIdentifier, path: devicePath, appId: appIdentifier }]);
2121
children = result[deviceIdentifier][0].response;
22-
this.$logger.out(children.join(EOL));
22+
this.$logger.info(children.join(EOL));
2323
}
2424

2525
public async getFile(deviceFilePath: string, appIdentifier: string, outputFilePath?: string): Promise<void> {
@@ -29,7 +29,7 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
2929
}
3030

3131
const fileContent = await this.getFileContent(deviceFilePath, appIdentifier);
32-
this.$logger.out(fileContent);
32+
this.$logger.info(fileContent);
3333
}
3434

3535
public async getFileContent(deviceFilePath: string, appIdentifier: string): Promise<string> {

lib/common/mobile/mobile-core/devices-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
606606
return;
607607
}
608608

609-
this.$logger.out("Searching for devices...");
609+
this.$logger.info("Searching for devices...");
610610

611611
deviceInitOpts = deviceInitOpts || {};
612612
this._data = deviceInitOpts;

lib/common/services/auto-completion-service.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class AutoCompletionService implements IAutoCompletionService {
9898
this.removeObsoleteAutoCompletion();
9999

100100
if (this.scriptsOk && this.scriptsUpdated) {
101-
this.$logger.out("Restart your shell to disable command auto-completion.");
101+
this.$logger.info("Restart your shell to disable command auto-completion.");
102102
}
103103
}
104104

@@ -108,7 +108,7 @@ export class AutoCompletionService implements IAutoCompletionService {
108108
this.removeObsoleteAutoCompletion();
109109

110110
if (this.scriptsOk && this.scriptsUpdated) {
111-
this.$logger.out("Restart your shell to enable command auto-completion.");
111+
this.$logger.info("Restart your shell to enable command auto-completion.");
112112
}
113113
}
114114

@@ -155,11 +155,11 @@ export class AutoCompletionService implements IAutoCompletionService {
155155
this.scriptsUpdated = true;
156156
}
157157
} catch (err) {
158-
this.$logger.out("Unable to update %s. Command-line completion might not work.", fileName);
158+
this.$logger.info("Unable to update %s. Command-line completion might not work.", fileName);
159159
// When npm is installed with sudo, in some cases the installation cannot write to shell profiles
160160
// Advise the user how to enable autocompletion after the installation is completed.
161161
if ((err.code === "EPERM" || err.code === "EACCES") && !this.$hostInfo.isWindows && process.env.SUDO_USER) {
162-
this.$logger.out("To enable command-line completion, run '$ %s autocomplete enable'.", this.$staticConfig.CLIENT_NAME);
162+
this.$logger.info("To enable command-line completion, run '$ %s autocomplete enable'.", this.$staticConfig.CLIENT_NAME);
163163
}
164164

165165
this.$logger.trace(err);
@@ -179,8 +179,8 @@ export class AutoCompletionService implements IAutoCompletionService {
179179
} catch (err) {
180180
// If file does not exist, autocompletion was not working for it, so ignore this error.
181181
if (err.code !== "ENOENT") {
182-
this.$logger.out("Failed to update %s. Auto-completion may still work or work incorrectly. ", fileName);
183-
this.$logger.out(err);
182+
this.$logger.info("Failed to update %s. Auto-completion may still work or work incorrectly. ", fileName);
183+
this.$logger.info(err);
184184
this.scriptsOk = false;
185185
}
186186
}
@@ -211,7 +211,7 @@ export class AutoCompletionService implements IAutoCompletionService {
211211
this.$fs.chmod(filePath, "0644");
212212
}
213213
} catch (err) {
214-
this.$logger.out("Failed to update %s. Auto-completion may not work. ", filePath);
214+
this.$logger.info("Failed to update %s. Auto-completion may not work. ", filePath);
215215
this.$logger.trace(err);
216216
this.scriptsOk = false;
217217
}

lib/common/test/unit-tests/mobile/android-device-file-system.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { AndroidDeviceFileSystem } from "../../../mobile/android/android-device-file-system";
22
import { Yok } from "../../../yok";
33
import { Errors } from "../../../errors";
4-
import { Logger } from "../../../logger";
4+
import { Logger } from "../../../logger/logger";
55
import { MobileHelper } from "../../../mobile/mobile-helper";
66
import { DevicePlatformsConstants } from "../../../mobile/device-platforms-constants";
77

lib/common/test/unit-tests/mobile/project-files-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { HostInfo } from "../../../host-info";
77
import { LocalToDevicePathDataFactory } from "../../../mobile/local-to-device-path-data-factory";
88
import { MobileHelper } from "../../../mobile/mobile-helper";
99
import { ProjectFilesManager } from "../../../services/project-files-manager";
10-
import { Logger } from "../../../logger";
10+
import { Logger } from "../../../logger/logger";
1111
import * as path from "path";
1212
import { Yok } from "../../../yok";
1313
import { ProjectFilesProviderBase } from "../../../services/project-files-provider-base";

lib/package-installation-manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class PackageInstallationManager implements IPackageInstallationManager {
9191
await this.$childProcess.exec(`npm install ${inspectorNpmPackageName}@${version} --prefix ${cachePath}`, { maxBuffer: 250 * 1024 });
9292
}
9393

94-
this.$logger.out("Using inspector from cache.");
94+
this.$logger.info("Using inspector from cache.");
9595
return pathToPackageInCache;
9696
}
9797

@@ -139,7 +139,7 @@ export class PackageInstallationManager implements IPackageInstallationManager {
139139
}
140140

141141
private async npmInstall(packageName: string, pathToSave: string, version: string, dependencyType: string): Promise<INpmInstallResultInfo> {
142-
this.$logger.out(`Installing ${packageName}`);
142+
this.$logger.info(`Installing ${packageName}`);
143143

144144
packageName = packageName + (version ? `@${version}` : "");
145145

lib/project-data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class ProjectData implements IProjectData {
260260

261261
@cache()
262262
private warnProjectId(): void {
263-
this.$logger.warnWithLabel("IProjectData.projectId is deprecated. Please use IProjectData.projectIdentifiers[platform].");
263+
this.$logger.warn("[WARNING]: IProjectData.projectId is deprecated. Please use IProjectData.projectIdentifiers[platform].");
264264
}
265265
}
266266
$injector.register("projectData", ProjectData, true);

lib/services/analytics/analytics-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class AnalyticsService implements IAnalyticsService, IDisposable {
3333
let trackFeatureUsage = initialTrackFeatureUsageStatus === AnalyticsStatus.enabled;
3434

3535
if (await this.isNotConfirmed(this.$staticConfig.TRACK_FEATURE_USAGE_SETTING_NAME) && isInteractive()) {
36-
this.$logger.out("Do you want to help us improve "
36+
this.$logger.info("Do you want to help us improve "
3737
+ this.$analyticsSettingsService.getClientName()
3838
+ " by automatically sending anonymous usage statistics? We will not use this information to identify or contact you."
3939
+ " You can read our official Privacy Policy at");

0 commit comments

Comments
 (0)