Skip to content

Commit

Permalink
Export logging types in neo4j-driver (#1115)
Browse files Browse the repository at this point in the history
The types was not exported causing issues when configure logs in typescript.
  • Loading branch information
bigmontz committed Jul 21, 2023
1 parent 43c4590 commit abae164
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/neo4j-driver/test/types/export.test.ts
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
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

0 comments on commit abae164

Please sign in to comment.