Skip to content

Commit 5cc6baf

Browse files
alexk-blackopsalexk-blackops
authored andcommitted
readme changes
1 parent bfbc804 commit 5cc6baf

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

README.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ All the details could be found here - [Winston Transport for Stackify](https://g
4545

4646
#### Using direct logger
4747

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:
4949
```js
5050
stackify.log(level, message, meta)
5151
stackify.trace(message, meta)
@@ -79,31 +79,35 @@ function (req, res, next) {
7979
next();
8080
}
8181

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 :
8484

85-
var http = require('http')
86-
var stackify = require('stackify-logger')
85+
```js
86+
var http = require('http');
87+
var stackify = require('stackify-logger');
8788
http.createServer(function (req, res) {
8889
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+
9396
You can use it also with any framework that doesn’t modify native createServer method.
9497

9598

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.
98101

99102
You can activate it with the app.use() command in the appropriate place of your code, e.g.:
103+
104+
```js
100105
var express = require('express');
101106
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+
```
105109

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.
107111

108112
## License
109113

0 commit comments

Comments
 (0)