Skip to content

Commit abae164

Browse files
authored
Export logging types in neo4j-driver (#1115)
The types was not exported causing issues when configure logs in typescript.
1 parent 43c4590 commit abae164

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/neo4j-driver/test/types/export.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const driverConfiguration0 = driver.driver('driver', undefined, {
6262

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

65+
const driverConfiguration2 = driver.driver('driver', undefined, {
66+
logging: driver.logging.console('debug')
67+
})
68+
6569
const session = new Session({
6670
mode: 'READ',
6771
connectionProvider: new ConnectionProvider(),

packages/neo4j-driver/types/index.d.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ import {
8686
notificationFilterMinimumSeverityLevel,
8787
AuthTokenManager,
8888
AuthTokenAndExpiration,
89-
expirationBasedAuthTokenManager
89+
expirationBasedAuthTokenManager,
90+
types as coreTypes
9091
} from 'neo4j-driver-core'
9192
import {
9293
AuthToken,
@@ -120,6 +121,18 @@ declare const auth: {
120121
) => AuthToken
121122
}
122123

124+
/**
125+
* Object containing predefined logging configurations. These are expected to be used as values of the driver config's `logging` property.
126+
* @property {function(level: ?string): object} console the function to create a logging config that prints all messages to `console.log` with
127+
* timestamp, level and message. It takes an optional `level` parameter which represents the maximum log level to be logged. Default value is 'info'.
128+
*/
129+
declare const logging: {
130+
console: (level: coreTypes.LogLevel) => {
131+
level: coreTypes.LogLevel
132+
logger: (level: coreTypes.LogLevel, message: string) => void
133+
}
134+
}
135+
123136
declare function driver (
124137
url: string,
125138
authToken?: AuthToken | AuthTokenManager,
@@ -269,6 +282,7 @@ declare const forExport: {
269282
notificationFilterDisabledCategory: typeof notificationFilterDisabledCategory
270283
notificationFilterMinimumSeverityLevel: typeof notificationFilterMinimumSeverityLevel
271284
expirationBasedAuthTokenManager: typeof expirationBasedAuthTokenManager
285+
logging: typeof logging
272286
}
273287

274288
export {
@@ -343,7 +357,8 @@ export {
343357
notificationSeverityLevel,
344358
notificationFilterDisabledCategory,
345359
notificationFilterMinimumSeverityLevel,
346-
expirationBasedAuthTokenManager
360+
expirationBasedAuthTokenManager,
361+
logging
347362
}
348363

349364
export type {

0 commit comments

Comments
 (0)