-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Add Consola integration #17435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+1,334
−23
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject-args.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Set consola level to capture all logs including debug and trace | ||
consola.level = 5; | ||
|
||
// Create a Sentry reporter for consola | ||
const sentryReporter = Sentry.createConsolaReporter(); | ||
|
||
// Add the reporter to consola | ||
consola.addReporter(sentryReporter); | ||
|
||
// Test with arguments formatting | ||
consola.info('Message with args:', 'hello', 123, { key: 'value' }, [1, 2, 3]); | ||
consola.error('Error with object:', new Error('Test error')); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
30 changes: 30 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject-custom-levels.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Test custom levels filtering | ||
const customReporter = Sentry.createConsolaReporter({ | ||
levels: ['error', 'warn'], // Only capture errors and warnings | ||
}); | ||
|
||
// Add the custom reporter to consola | ||
consola.addReporter(customReporter); | ||
|
||
consola.info('This should not be captured'); | ||
consola.warn('This should be captured'); | ||
consola.error('This should also be captured'); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
32 changes: 32 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject-levels.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Set consola level to capture all logs including debug and trace | ||
consola.level = 5; | ||
|
||
// Create a Sentry reporter for consola | ||
const sentryReporter = Sentry.createConsolaReporter(); | ||
|
||
// Add the reporter to consola | ||
consola.addReporter(sentryReporter); | ||
|
||
// Test level-based logging - test some basic level mappings by using different log methods | ||
consola.fatal('Fatal level message'); | ||
consola.warn('Warning level message'); | ||
consola.info('Info level message'); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
32 changes: 32 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject-tags.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Set consola level to capture all logs including debug and trace | ||
consola.level = 5; | ||
|
||
// Create a Sentry reporter for consola | ||
const sentryReporter = Sentry.createConsolaReporter(); | ||
|
||
// Add the reporter to consola | ||
consola.addReporter(sentryReporter); | ||
|
||
// Test with scoped logger (tags) | ||
const taggedLogger = consola.withTag('api'); | ||
taggedLogger.info('Tagged info message'); | ||
taggedLogger.error('Tagged error message'); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
42 changes: 42 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject-types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Set consola level to capture all logs including debug, trace, and verbose | ||
consola.level = Number.POSITIVE_INFINITY; | ||
|
||
// Create a Sentry reporter for consola | ||
const sentryReporter = Sentry.createConsolaReporter(); | ||
|
||
// Add the reporter to consola | ||
consola.addReporter(sentryReporter); | ||
|
||
// Test basic logging with different types | ||
consola.info('Test info message'); | ||
consola.error('Test error message'); | ||
consola.warn('Test warn message'); | ||
|
||
// Test different consola log types | ||
consola.success('Test success message'); | ||
consola.fail('Test fail message'); | ||
consola.ready('Test ready message'); | ||
consola.start('Test start message'); | ||
consola.box('Test box message'); | ||
consola.verbose('Test verbose message'); | ||
consola.debug('Test debug message'); | ||
consola.trace('Test trace message'); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
32 changes: 32 additions & 0 deletions
dev-packages/node-integration-tests/suites/consola/subject.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as Sentry from '@sentry/node'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import { consola } from 'consola'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0.0', | ||
environment: 'test', | ||
enableLogs: true, | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Set consola level to capture all logs including debug and trace | ||
consola.level = 5; | ||
|
||
// Create a Sentry reporter for consola | ||
const sentryReporter = Sentry.createConsolaReporter(); | ||
|
||
// Add the reporter to consola | ||
consola.addReporter(sentryReporter); | ||
|
||
// Test basic logging with different types | ||
consola.info('Test info message'); | ||
consola.error('Test error message'); | ||
consola.warn('Test warn message'); | ||
|
||
await Sentry.flush(); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
void run(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.