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
Previous solution where only the logger function is configured had a
potential drawback - all log messages needed to be constructed even
when user is only interested in a certain log level. E.g. debug
messages that stringify returned values had to be created even if user
is only interested in 'info' level.
This commit addresses the problem by making the log level configurable.
Driver configuration now looks like:
```
const config = {
logging: {
level: 'debug',
logger: (level, message) => console.log(level + ' ' + message)
}
};
const driver = neo4j.driver(
'bolt://localhost',
neo4j.auth.basic('neo4j', 'password'),
config
);
```
to enable logging of all currently supported log levels.
Levels have priorities like:
```
error: 0
warn: 1
info: 2
debug: 3
```
Enabling a certain level also enables logging of all levels with lower
priorities. When 'info' is enabled, logger will output 'error', 'warn',
'info' but not 'debug'. Level configuration is optional, 'info' is the
default value.
* 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>
* // Specify the logging configuration for the driver. Object should have two properties <code>level</code> and <code>logger</code>.
189
+
* //
190
+
* // Property <code>level</code> represents the logging level which should be one of: 'error', 'warn', 'info' or 'debug'. This property is optional and
191
+
* // its default value is 'info'. Levels have priorities: 'error': 0, 'warn': 1, 'info': 2, 'debug': 3. Enabling a certain level also enables all
192
+
* // levels with lower priority. For example: 'error', 'warn' and 'info' will be logged when 'info' level is configured.
193
+
* //
194
+
* // Property <code>logger</code> represents the logging function which will be invoked for every log call with an acceptable level. The function should
195
+
* // take two string arguments <code>level</code> and <code>message</code>. The function should not execute any blocking or long-running operations
196
+
* // because it is often executed on a hot path.
197
+
* //
198
+
* // No logging is done by default. See <code>neo4j.logging</code> object that contains predefined logging implementations.
0 commit comments