Skip to content

Commit af50c33

Browse files
committed
refactor: Ensure proper verbose progress logs
1 parent 4b9c1a0 commit af50c33

File tree

7 files changed

+19
-22
lines changed

7 files changed

+19
-22
lines changed

lib/clean.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ function cleanupCache() {
4040
if (fse.existsSync(cacheLocation)) {
4141
let cleanupProgress;
4242
if (this.serverless) {
43-
if (this.progress) {
43+
if (this.progress && this.log) {
4444
cleanupProgress = this.progress.get('python-cleanup-cache');
45-
cleanupProgress.notice(`Removing static caches at: ${cacheLocation}`, {
46-
isMainEvent: true,
47-
});
45+
cleanupProgress.notice('Removing static caches');
46+
this.log.info(`Removing static caches at: ${cacheLocation}`);
4847
} else {
4948
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
5049
}

lib/inject.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ function injectAllRequirements(funcArtifact) {
9393
}
9494

9595
let injectProgress;
96-
if (this.progress) {
96+
if (this.progress && this.log) {
9797
injectProgress = this.progress.get('python-inject-requirements');
98-
injectProgress.update('Injecting required Python packages to package', {
99-
isMainEvent: true,
100-
});
98+
injectProgress.update('Injecting required Python packages to package');
99+
this.log.info('Injecting required Python packages to package');
101100
} else {
102101
this.serverless.cli.log('Injecting required Python packages to package...');
103102
}

lib/layer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ function layerRequirements() {
5454
}
5555

5656
let layerProgress;
57-
if (this.progress) {
57+
if (this.progress && this.log) {
5858
layerProgress = this.progress.get('python-layer-requirements');
59-
layerProgress.update('Packaging Python Requirements Lambda Layer', {
60-
isMainEvent: true,
61-
});
59+
layerProgress.update('Packaging Python Requirements Lambda Layer');
60+
this.log.info('Packaging Python Requirements Lambda Layer');
6261
} else {
6362
this.serverless.cli.log('Packaging Python Requirements Lambda Layer...');
6463
}

lib/pip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ async function installAllRequirements() {
716716
const reqsInstalledAt = await installRequirementsIfNeeded(
717717
f.module,
718718
f,
719-
this.serverless
719+
this
720720
);
721721
// Add modulePath into .serverless for each module so it's easier for injecting and for users to see where reqs are
722722
let modulePath = path.join(

lib/pipenv.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ async function pipfileToRequirements() {
1515
}
1616

1717
let generateRequirementsProgress;
18-
if (this.progress) {
18+
if (this.progress && this.log) {
1919
generateRequirementsProgress = this.progress.get(
2020
'python-generate-requirements-pipfile'
2121
);
2222
generateRequirementsProgress.update(
23-
'Generating requirements.txt from Pipfile',
24-
{ isMainEvent: true }
23+
'Generating requirements.txt from Pipfile'
2524
);
25+
this.log.info('Generating requirements.txt from Pipfile');
2626
} else {
2727
this.serverless.cli.log('Generating requirements.txt from Pipfile...');
2828
}

lib/poetry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ async function pyprojectTomlToRequirements() {
1414
}
1515

1616
let generateRequirementsProgress;
17-
if (this.progress) {
17+
if (this.progress && this.log) {
1818
generateRequirementsProgress = this.progress.get(
1919
'python-generate-requirements-toml'
2020
);
2121
generateRequirementsProgress.update(
22-
'Generating requirements.txt from "pyproject.toml"',
23-
{ isMainEvent: true }
22+
'Generating requirements.txt from "pyproject.toml"'
2423
);
24+
this.log.info('Generating requirements.txt from "pyproject.toml"');
2525
} else {
2626
this.serverless.cli.log(
2727
'Generating requirements.txt from pyproject.toml...'

lib/zip.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ function packRequirements() {
123123
.then((funcs) => uniqBy(funcs, (f) => f.module))
124124
.map((f) => {
125125
let packProgress;
126-
if (this.progress) {
126+
if (this.progress && this.log) {
127127
packProgress = this.progress.get(
128128
`python-pack-requirements-${f.module}`
129129
);
130130
packProgress.update(
131-
`Zipping required Python packages for ${f.module}`,
132-
{ isMainEvent: true }
131+
`Zipping required Python packages for ${f.module}`
133132
);
133+
this.log.info(`Zipping required Python packages for ${f.module}`);
134134
} else {
135135
this.serverless.cli.log(
136136
`Zipping required Python packages for ${f.module}...`

0 commit comments

Comments
 (0)