Skip to content

Commit 96e54dd

Browse files
author
naman-contentstack
committed
updated logger
1 parent 70c2ee8 commit 96e54dd

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

packages/contentstack-import/src/import/module-importer.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { resolve } from 'path';
22
import { AuditFix } from '@contentstack/cli-audit';
33
import messages, { $t } from '@contentstack/cli-audit/lib/messages';
4-
import { addLocale, cliux, ContentstackClient, Logger } from '@contentstack/cli-utilities';
4+
import { addLocale, cliux, ContentstackClient, Logger, log } from '@contentstack/cli-utilities';
55

66
import startModuleImport from './modules';
77
import startJSModuleImport from './modules-js';
88
import { ImportConfig, Modules } from '../types';
99
import {
1010
backupHandler,
11-
log,
1211
masterLocalDetails,
1312
sanitizeStack,
1413
initLogger,
@@ -87,7 +86,7 @@ class ModuleImporter {
8786
}
8887

8988
async import() {
90-
log(this.importConfig, `Starting to import content version ${this.importConfig.contentVersion}`, 'info');
89+
log.info(`Starting to import content version ${this.importConfig.contentVersion}`);
9190

9291
// checks for single module or all modules
9392
if (this.importConfig.singleModuleImport) {
@@ -97,7 +96,7 @@ class ModuleImporter {
9796
}
9897

9998
async importByModuleByName(moduleName: Modules) {
100-
log(this.importConfig, `Starting import of ${moduleName} module`, 'info');
99+
log.info(`Starting import of ${moduleName} module`);
101100
// import the modules by name
102101
// calls the module runner which inturn calls the module itself
103102
// NOTE: Implement a mechanism to determine whether module is new or old
@@ -123,11 +122,7 @@ class ModuleImporter {
123122
// use the algorithm to determine the parallel and sequential execution of modules
124123
for (let moduleName of this.importConfig.modules.types) {
125124
if (this.importConfig.globalModules.includes(moduleName) && this.importConfig['exclude-global-modules']) {
126-
log(
127-
this.importConfig,
128-
`Skipping the import of the global module '${moduleName}', as it already exists in the stack.`,
129-
'warn',
130-
);
125+
log.warn(`Skipping the import of the global module '${moduleName}', as it already exists in the stack.`);
131126
continue;
132127
}
133128
await this.importByModuleByName(moduleName);
@@ -141,9 +136,9 @@ class ModuleImporter {
141136
private async resolveImportPath(): Promise<void> {
142137
try {
143138
const resolvedPath = await executeImportPathLogic(this.importConfig, this.stackAPIClient);
144-
log(this.importConfig, `Import path resolved to: ${resolvedPath}`, 'debug');
139+
log.debug(`Import path resolved to: ${resolvedPath}`);
145140
} catch (error) {
146-
log(this.importConfig, `Failed to resolve import path: ${error}`, 'error');
141+
log.error(`Failed to resolve import path: ${error}`);
147142
// Continue with original path if resolution fails
148143
}
149144
}
@@ -183,9 +178,9 @@ class ModuleImporter {
183178
});
184179
}
185180
args.push('--modules', 'field-rules');
186-
log(this.importConfig, 'Starting audit process', 'info');
181+
log.info('Starting audit process');
187182
const result = await AuditFix.run(args);
188-
log(this.importConfig, 'Audit process completed', 'info');
183+
log.info('Audit process completed');
189184

190185
if (result) {
191186
const { hasFix, config } = result;
@@ -211,7 +206,7 @@ class ModuleImporter {
211206

212207
return true;
213208
} catch (error) {
214-
log(this.importConfig, `Audit failed with following error. ${error}`, 'error');
209+
log.error(`Audit failed with following error. ${error}`);
215210
}
216211
}
217212
}

0 commit comments

Comments
 (0)