Commit f2fc68c
committed
Support configurable logging
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.1 parent 2c2ae55 commit f2fc68c
File tree
14 files changed
+400
-59
lines changed- src/v1
- internal
- test
- internal
- v1
- types/v1
14 files changed
+400
-59
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| 72 | + | |
69 | 73 | | |
70 | 74 | | |
71 | | - | |
72 | | - | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | | - | |
| 83 | + | |
| 84 | + | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
90 | 104 | | |
91 | 105 | | |
92 | 106 | | |
| |||
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
121 | | - | |
122 | | - | |
| 135 | + | |
123 | 136 | | |
124 | 137 | | |
125 | | - | |
126 | 138 | | |
127 | 139 | | |
128 | | - | |
| 140 | + | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
| |||
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
148 | | - | |
149 | | - | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
153 | | - | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
224 | 236 | | |
225 | 237 | | |
226 | 238 | | |
227 | | - | |
228 | | - | |
229 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
230 | 244 | | |
231 | 245 | | |
232 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
175 | 190 | | |
176 | 191 | | |
177 | 192 | | |
| |||
280 | 295 | | |
281 | 296 | | |
282 | 297 | | |
| 298 | + | |
283 | 299 | | |
284 | 300 | | |
285 | 301 | | |
| |||
301 | 317 | | |
302 | 318 | | |
303 | 319 | | |
| 320 | + | |
304 | 321 | | |
305 | 322 | | |
306 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | 375 | | |
377 | 376 | | |
378 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| 240 | + | |
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
| |||
0 commit comments