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
Copy file name to clipboardExpand all lines: README.md
+5-25Lines changed: 5 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The following options could be passed. 'apiKey' is the only one that required:
29
29
*__exitOnError:__ boolean flag indicating whether to shutdown the server after logging an uncaught exception, defaults to false
30
30
*__proxy:__ proxy server if you want to send requests via proxy.
31
31
32
-
*Notice:* stackify-logger sends synchronous requests before any `process.exit()` calls in your code. Sending via proxy wouldn't be possible in this case.
32
+
*Notice:* stackify-logger sends synchronous requests if you call `process.exit()`. Sending via proxy wouldn't be possible in this case.
**meta1 ... metaN** - a list of additional parameters of any type.
64
64
65
-
The timestamp will be added to every message by default.
66
-
67
65
Examples of usage:
68
66
```js
69
67
// Add the module to all the script files where you want to log any messages.
@@ -75,33 +73,15 @@ stackify.info('any message', {anything: 'this is metadata'});
75
73
stackify.warn('attention');
76
74
stackify.log('error', {error :newError()});
77
75
```
78
-
When logging an error message you could pass an Error object in metadata like in the last case so the exception details would be available.
76
+
When logging an error message you can pass an Error object in metadata like in the last example, so the exception details would be available.
79
77
80
78
#### Exception handling
81
-
By executing `stackify.start()` you set handler for uncaught exceptions.
82
-
Be sure to run it before any methods that set exception handlers.
83
-
84
-
##### Using with pure NodeJS app
85
-
If you want to get web details of an exception to be sent with it you should run `stackify.exceptionHandler(req)` first line inside of native `createServer` method :
86
-
87
-
```js
88
-
var http =require('http');
89
-
var stackify =require('stackify-logger');
90
-
http.createServer(function (req, res) {
91
-
stackify.exceptionHandler(req);
92
-
res.setHeader('content-type', 'text/plain');
93
-
res.end('hello');
94
-
});
95
-
});
96
-
```
97
-
where req is request object, an instance of native NodeJS `http.IncomingMessage` object
98
-
99
-
You can use it also with any framework that doesn’t modify native createServer method.
100
-
79
+
By executing `stackify.start()` you set a handler for uncaught exceptions.
80
+
Make sure you run it before any methods that set exception handlers.
101
81
102
82
##### Using with Express
103
83
Global handler doesn't work inside Express route methods.
104
-
You should use error-handling middleware function `stackify.expressExceptionHandler`. Since middleware is executed serially, it's order of inclusion is important. Be sure to add it before any other error-handling middleware.
84
+
You should use error-handling middleware function `stackify.expressExceptionHandler`. Since middleware is executed serially, it's order of inclusion is important. Make sure you add it before any other error-handling middleware.
0 commit comments