You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit makes driver able to log internal events to the configured
logging destination. Produced log messages should give an insight into
what operations are happening inside the driver. Logging destination
can be configured for the driver in the config object:
```
const config = {
logger: (level, message) => console.log(level + ' ' + message)
};
const driver = neo4j.driver(
'bolt://localhost',
neo4j.auth.basic('neo4j', 'password'),
config
);
```
Property `logger` should be a function that takes two arguments
`level: string` and `message: string`. Log level can now be 'error',
'warn', 'info' or 'debug'. Function should not execute any blocking or
long-running operations because it is often invoked on a hot path.
There exists a predefined logger implementation which outputs timestamp,
log level and message. Example:
```
1527703465096 INFO Direct driver 0 created for server address localhost:7687
```
It is defined in the `neo4j.logger` object and can be used like this:
```
const config = {
logger: neo4j.logger.console
};
const driver = neo4j.driver(
'bolt://localhost',
neo4j.auth.basic('neo4j', 'password'),
config
);
```
Users of the driver should be able to plug in an existing logging
framework like https://github.com/winstonjs/winston.
Copy file name to clipboardExpand all lines: src/v1/index.js
+17
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,14 @@ const auth = {
68
68
};
69
69
constUSER_AGENT="neo4j-javascript/"+VERSION;
70
70
71
+
/**
72
+
* Object containing predefined logger implementations. These are expected to be used as values of the driver config's <code>logger</code> property.
73
+
* @property {function(level: string, message: string)} console the logger function that outputs timestamp, log level and message to <code>console.log()</code>
0 commit comments