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
+19-15Lines changed: 19 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ All the details could be found here - [Winston Transport for Stackify](https://g
45
45
46
46
#### Using direct logger
47
47
48
-
If you are not using Winston logger you can use default Stackify logger. It has 5 levels of messages: trace, debug, info, warn and error. To send the message to Stackify API you should run one of the following methods in any place of your code where you want to track some information:
48
+
If you are not using Winston logger you can use default Stackify logger. It has 5 levels of messages: `trace`, `debug`, `info`, `warn` and `error`. To send the message to Stackify API you should run one of the following methods in any place of your code where you want to track some information:
49
49
```js
50
50
stackify.log(level, message, meta)
51
51
stackify.trace(message, meta)
@@ -79,31 +79,35 @@ function (req, res, next) {
79
79
next();
80
80
}
81
81
82
-
Using with pure NodeJS app
83
-
If you are not using any of the frameworks and all requests are handled inside native createServer method you should run stackify.stats() first line inside of this method :
82
+
##### Using with pure NodeJS app
83
+
If you are not using any of the frameworks and all requests are handled inside native createServer method you should run stackify.exceptionHandler() first line inside of this method :
84
84
85
-
var http = require('http')
86
-
var stackify = require('stackify-logger')
85
+
```js
86
+
var http =require('http');
87
+
var stackify =require('stackify-logger');
87
88
http.createServer(function (req, res) {
88
89
stackify.stats(req, res);
89
-
res.setHeader('content-type', 'text/plain')
90
-
res.end('hello')
91
-
})
92
-
})
90
+
res.setHeader('content-type', 'text/plain');
91
+
res.end('hello');
92
+
});
93
+
});
94
+
```
95
+
93
96
You can use it also with any framework that doesn’t modify native createServer method.
94
97
95
98
96
-
Using with express
97
-
It acts as middleware when running on express-based apps. A middleware is a function which has access to request object (req) and response object (res), and the next middleware in line in the request-response cycle of an Express application (next). Each middleware can execute any code, make changes to request and response object, finish request-response cycle, and call the next middleware in the stack. Since middleware are execute serially, their order of inclusion is important.
99
+
##### Using with Express
100
+
It acts as middleware when running on express-based apps. Since middleware are execute serially, their order of inclusion is important.
98
101
99
102
You can activate it with the app.use() command in the appropriate place of your code, e.g.:
103
+
104
+
```js
100
105
var express =require('express');
101
106
var app =express();
102
-
app.use(stackify.stats);
103
-
104
-
To handle exceptions correctly put this right after all route handlers and before all the other app.use() commands.
107
+
app.use(stackify.expressExceptionHandler());
108
+
```
105
109
106
-
To use it with the frameworks that have a wrapper around app.use() method or have different ways to use middleware plugins you should check the exact way of using middleware in it. For example, to add stackify.stats in SailsJS you should do this
110
+
To handle exceptions correctly put this right after all route handlers and before all the other error middleware.
0 commit comments