Skip to content

Commit 63103d0

Browse files
authored
chore: prefer apify logger instead of console.log (#591)
Closes #565
1 parent b7c6ce8 commit 63103d0

File tree

10 files changed

+14
-21
lines changed

10 files changed

+14
-21
lines changed

templates/js-cypress/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"node": ">=18.0.0"
88
},
99
"dependencies": {
10-
"@apify/log": "^2.5.20",
1110
"apify": "^3.4.2",
1211
"console.table": "^0.10.0",
1312
"cypress": "^15.0.0",

templates/js-cypress/src/main.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ import 'console.table';
44

55
import fs from 'node:fs';
66

7-
import { Actor } from 'apify';
7+
import { Actor, log } from 'apify';
88
// Component and E2E testing library (read more at https://docs.cypress.io/guides/overview/why-cypress)
99
import cypress from 'cypress';
1010
// File system traversing library (read more at https://www.jsdocs.io/package/globby)
1111
import { globby } from 'globby';
1212

13-
// Apify logging utility library
14-
import log from '@apify/log';
15-
1613
// this is ESM project, and as such, it requires you to specify extensions in your relative imports
1714
// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions
1815
// import { router } from './routes.js';

templates/js-empty/src/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/)
2-
import { Actor } from 'apify';
2+
import { Actor, log } from 'apify';
33
// Crawlee - web scraping and browser automation library (Read more at https://crawlee.dev)
44
// import { CheerioCrawler } from 'crawlee';
55

@@ -11,7 +11,7 @@ import { Actor } from 'apify';
1111
await Actor.init();
1212

1313
// eslint-disable-next-line no-console
14-
console.log('Hello from the Actor!');
14+
log.info('Hello from the Actor!');
1515
/**
1616
* Actor code
1717
*/

templates/js-start/src/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/).
2-
import { Actor } from 'apify';
2+
import { Actor, log } from 'apify';
33
// Axios - Promise based HTTP client for the browser and node.js (Read more at https://axios-http.com/docs/intro).
44
import axios from 'axios';
55
// Cheerio - The fast, flexible & elegant library for parsing and manipulating HTML and XML (Read more at https://cheerio.js.org/).
@@ -28,7 +28,7 @@ $('h1, h2, h3, h4, h5, h6').each((i, element) => {
2828
level: $(element).prop('tagName').toLowerCase(),
2929
text: $(element).text(),
3030
};
31-
console.log('Extracted heading', headingObject);
31+
log.info('Extracted heading', headingObject);
3232
headings.push(headingObject);
3333
});
3434

templates/ts-empty/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/)
2-
import { Actor } from 'apify';
2+
import { Actor, log } from 'apify';
33
// Crawlee - web scraping and browser automation library (Read more at https://crawlee.dev)
44
// import { CheerioCrawler } from 'crawlee';
55

@@ -11,7 +11,7 @@ import { Actor } from 'apify';
1111
// The init() call configures the Actor for its environment. It's recommended to start every Actor with an init()
1212
await Actor.init();
1313

14-
console.log('Hello from the Actor!');
14+
log.info('Hello from the Actor!');
1515
/**
1616
* Actor code
1717
*/

templates/ts-mcp-proxy/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export async function startServer(options: { serverPort: number; command: string
211211
// Readiness probe handler
212212
app.get('/', (req: Request, res: Response) => {
213213
if (req.headers['x-apify-container-server-readiness-probe']) {
214-
console.log('Readiness probe');
214+
log.info('Readiness probe');
215215
res.end('ok\n');
216216
return;
217217
}

templates/ts-playwright-test-runner/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"@playwright/test": "1.54.1",
2424
"@types/uuid": "^11.0.0",
2525
"apify": "^3.4.2",
26-
"@apify/log": "^2.5.20",
2726
"uuid": "^13.0.0",
2827
"@apify/eslint-config": "^1.0.0",
2928
"@apify/tsconfig": "^0.1.1",

templates/ts-playwright-test-runner/src/main.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { execSync } from 'node:child_process';
22
import fs from 'node:fs';
33
import path from 'node:path';
44

5-
import { Actor } from 'apify';
5+
import { Actor, log } from 'apify';
66
import type { Dictionary } from 'apify-client';
77

8-
import log from '@apify/log';
9-
108
import { collectAttachmentPaths, transformToTabular } from './transform.js';
119

1210
function ensureFolder(pathname: string) {
@@ -133,6 +131,6 @@ await Actor.pushData(transformToTabular(jsonReport, attachmentLinks));
133131

134132
const reportURL = kvs.getPublicUrl('report');
135133
log.info('The test run has finished! The report is available in the Output tab or at the link below:');
136-
console.log(reportURL);
134+
log.info(reportURL);
137135

138136
await Actor.exit();

templates/ts-start-bun/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/).
2-
import { Actor } from 'apify';
2+
import { Actor, log } from 'apify';
33
// Axios - Promise based HTTP client for the browser and node.js (Read more at https://axios-http.com/docs/intro).
44
import axios from 'axios';
55
// Cheerio - The fast, flexible & elegant library for parsing and manipulating HTML and XML (Read more at https://cheerio.js.org/).
@@ -34,7 +34,7 @@ $('h1, h2, h3, h4, h5, h6').each((_i, element) => {
3434
level: $(element).prop('tagName')!.toLowerCase(),
3535
text: $(element).text(),
3636
};
37-
console.log('Extracted heading', headingObject);
37+
log.info('Extracted heading', headingObject);
3838
headings.push(headingObject);
3939
});
4040

templates/ts-start/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Apify SDK - toolkit for building Apify Actors (Read more at https://docs.apify.com/sdk/js/).
2-
import { Actor } from 'apify';
2+
import { Actor, log } from 'apify';
33
// Axios - Promise based HTTP client for the browser and node.js (Read more at https://axios-http.com/docs/intro).
44
import axios from 'axios';
55
// Cheerio - The fast, flexible & elegant library for parsing and manipulating HTML and XML (Read more at https://cheerio.js.org/).
@@ -34,7 +34,7 @@ $('h1, h2, h3, h4, h5, h6').each((_i, element) => {
3434
level: $(element).prop('tagName')!.toLowerCase(),
3535
text: $(element).text(),
3636
};
37-
console.log('Extracted heading', headingObject);
37+
log.info('Extracted heading', headingObject);
3838
headings.push(headingObject);
3939
});
4040

0 commit comments

Comments
 (0)