Skip to content

Commit fcdc1aa

Browse files
author
kumar-ankita
committed
adding logger class
1 parent e2d4bca commit fcdc1aa

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/commands/omnistudio/migration/migrate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { MigrationResult, MigrationTool } from '../../../migration/interfaces';
1818
import { ResultsBuilder } from '../../../utils/resultsbuilder';
1919
import { CardMigrationTool } from '../../../migration/flexcard';
2020
import { OmniScriptExportType, OmniScriptMigrationTool } from '../../../migration/omniscript';
21+
import { Logger } from '../../../utils/logger';
2122

2223
// Initialize Messages with the current plugin directory
2324
Messages.importMessagesDirectory(__dirname);
@@ -48,14 +49,15 @@ export default class Migrate extends OmniStudioBaseCommand {
4849
required: false,
4950
}),
5051
};
52+
private logger: Logger;
5153

5254
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5355
public async run(): Promise<any> {
5456
const namespace = (this.flags.namespace || 'vlocity_ins') as string;
5557
const apiVersion = (this.flags.apiversion || '55.0') as string;
5658
const migrateOnly = (this.flags.only || '') as string;
5759
const allVersions = this.flags.allversions || false;
58-
60+
this.logger = new Logger(this.ux, this.logger);
5961
// this.org is guaranteed because requiresUsername=true, as opposed to supportsUsername
6062
const conn = this.org.getConnection();
6163
conn.setApiVersion(apiVersion);
@@ -126,7 +128,7 @@ export default class Migrate extends OmniStudioBaseCommand {
126128
let allTruncateComplete = true;
127129
for (const cls of migrationObjects.reverse()) {
128130
try {
129-
this.ux.log('Cleaning: ' + cls.getName());
131+
this.logger.log('Cleaning: ' + cls.getName());
130132
debugTimer.lap('Cleaning: ' + cls.getName());
131133
await cls.truncate();
132134
} catch (ex: any) {

src/utils/logger.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { UX } from '@salesforce/command';
2+
import { Logger as SfLogger } from '@salesforce/core';
3+
4+
export class Logger {
5+
private ux: UX;
6+
private logger: SfLogger;
7+
8+
constructor(ux: UX, logger: SfLogger) {
9+
this.ux = ux;
10+
this.logger = logger;
11+
}
12+
13+
public log(message: string): void {
14+
this.ux.log(message);
15+
}
16+
17+
public error(message: string): void {
18+
this.logger.error(message);
19+
}
20+
21+
public debug(message: string): void {
22+
this.logger.debug(message);
23+
}
24+
25+
// You can add more logging methods as needed
26+
}

0 commit comments

Comments
 (0)