Skip to content

Export logging types in neo4j-driver #1115

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

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/neo4j-driver/test/types/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const driverConfiguration0 = driver.driver('driver', undefined, {

const driverConfiguration1 = driver.driver('driver', undefined, {})

const driverConfiguration2 = driver.driver('driver', undefined, {
logging: driver.logging.console('debug')
})

const session = new Session({
mode: 'READ',
connectionProvider: new ConnectionProvider(),
Expand Down
19 changes: 17 additions & 2 deletions packages/neo4j-driver/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ import {
notificationFilterMinimumSeverityLevel,
AuthTokenManager,
AuthTokenAndExpiration,
expirationBasedAuthTokenManager
expirationBasedAuthTokenManager,
types as coreTypes
} from 'neo4j-driver-core'
import {
AuthToken,
Expand Down Expand Up @@ -120,6 +121,18 @@ declare const auth: {
) => AuthToken
}

/**
* Object containing predefined logging configurations. These are expected to be used as values of the driver config's `logging` property.
* @property {function(level: ?string): object} console the function to create a logging config that prints all messages to `console.log` with
* timestamp, level and message. It takes an optional `level` parameter which represents the maximum log level to be logged. Default value is 'info'.
*/
declare const logging: {
console: (level: coreTypes.LogLevel) => {
level: coreTypes.LogLevel
logger: (level: coreTypes.LogLevel, message: string) => void
}
}

declare function driver (
url: string,
authToken?: AuthToken | AuthTokenManager,
Expand Down Expand Up @@ -269,6 +282,7 @@ declare const forExport: {
notificationFilterDisabledCategory: typeof notificationFilterDisabledCategory
notificationFilterMinimumSeverityLevel: typeof notificationFilterMinimumSeverityLevel
expirationBasedAuthTokenManager: typeof expirationBasedAuthTokenManager
logging: typeof logging
}

export {
Expand Down Expand Up @@ -343,7 +357,8 @@ export {
notificationSeverityLevel,
notificationFilterDisabledCategory,
notificationFilterMinimumSeverityLevel,
expirationBasedAuthTokenManager
expirationBasedAuthTokenManager,
logging
}

export type {
Expand Down