Skip to content

Commit a1b1ade

Browse files
committed
feat(core): Add Consola integration
1 parent 5ee2597 commit a1b1ade

File tree

25 files changed

+1377
-23
lines changed

25 files changed

+1377
-23
lines changed

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"apollo-server": "^3.11.1",
4040
"body-parser": "^1.20.3",
4141
"connect": "^3.7.0",
42+
"consola": "^3.2.3",
4243
"cors": "^2.8.5",
4344
"cron": "^3.1.6",
4445
"dataloader": "2.2.2",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Set consola level to capture all logs including debug and trace
15+
consola.level = 5;
16+
17+
// Create a Sentry reporter for consola
18+
const sentryReporter = Sentry.createConsolaReporter();
19+
20+
// Add the reporter to consola
21+
consola.addReporter(sentryReporter);
22+
23+
// Test with arguments formatting
24+
consola.info('Message with args:', 'hello', 123, { key: 'value' }, [1, 2, 3]);
25+
consola.error('Error with object:', new Error('Test error'));
26+
27+
await Sentry.flush();
28+
}
29+
30+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
31+
void run();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Test custom levels filtering
15+
const customReporter = Sentry.createConsolaReporter({
16+
levels: ['error', 'warn'], // Only capture errors and warnings
17+
});
18+
19+
// Add the custom reporter to consola
20+
consola.addReporter(customReporter);
21+
22+
consola.info('This should not be captured');
23+
consola.warn('This should be captured');
24+
consola.error('This should also be captured');
25+
26+
await Sentry.flush();
27+
}
28+
29+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
30+
void run();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Set consola level to capture all logs including debug and trace
15+
consola.level = 5;
16+
17+
// Create a Sentry reporter for consola
18+
const sentryReporter = Sentry.createConsolaReporter();
19+
20+
// Add the reporter to consola
21+
consola.addReporter(sentryReporter);
22+
23+
// Test level-based logging - test some basic level mappings by using different log methods
24+
consola.fatal('Fatal level message');
25+
consola.warn('Warning level message');
26+
consola.info('Info level message');
27+
28+
await Sentry.flush();
29+
}
30+
31+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
32+
void run();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Set consola level to capture all logs including debug and trace
15+
consola.level = 5;
16+
17+
// Create a Sentry reporter for consola
18+
const sentryReporter = Sentry.createConsolaReporter();
19+
20+
// Add the reporter to consola
21+
consola.addReporter(sentryReporter);
22+
23+
// Test with scoped logger (tags)
24+
const taggedLogger = consola.withTag('api');
25+
taggedLogger.info('Tagged info message');
26+
taggedLogger.error('Tagged error message');
27+
28+
await Sentry.flush();
29+
}
30+
31+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
32+
void run();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Set consola level to capture all logs including debug, trace, and verbose
15+
consola.level = Number.POSITIVE_INFINITY;
16+
17+
// Create a Sentry reporter for consola
18+
const sentryReporter = Sentry.createConsolaReporter();
19+
20+
// Add the reporter to consola
21+
consola.addReporter(sentryReporter);
22+
23+
// Test basic logging with different types
24+
consola.info('Test info message');
25+
consola.error('Test error message');
26+
consola.warn('Test warn message');
27+
28+
// Test different consola log types
29+
consola.success('Test success message');
30+
consola.fail('Test fail message');
31+
consola.ready('Test ready message');
32+
consola.start('Test start message');
33+
consola.box('Test box message');
34+
consola.verbose('Test verbose message');
35+
consola.debug('Test debug message');
36+
consola.trace('Test trace message');
37+
38+
await Sentry.flush();
39+
}
40+
41+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
42+
void run();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
import { consola } from 'consola';
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
release: '1.0.0',
8+
environment: 'test',
9+
enableLogs: true,
10+
transport: loggingTransport,
11+
});
12+
13+
async function run(): Promise<void> {
14+
// Set consola level to capture all logs including debug and trace
15+
consola.level = 5;
16+
17+
// Create a Sentry reporter for consola
18+
const sentryReporter = Sentry.createConsolaReporter();
19+
20+
// Add the reporter to consola
21+
consola.addReporter(sentryReporter);
22+
23+
// Test basic logging with different types
24+
consola.info('Test info message');
25+
consola.error('Test error message');
26+
consola.warn('Test warn message');
27+
28+
await Sentry.flush();
29+
}
30+
31+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
32+
void run();

0 commit comments

Comments
 (0)