Skip to content

Commit 0b2451a

Browse files
committed
Merge pull request #2 from stackify/simplify-metadata
Simplify Metadata Handling
2 parents b8cf294 + 325e4f5 commit 0b2451a

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

README.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,21 @@ The following options could be passed. 'apiKey' is the only one that required:
3131

3232
*Notice:* stackify-logger sends synchronous requests if you call `process.exit()`. Sending via proxy wouldn't be possible in this case.
3333

34-
#### Using with Winston
35-
36-
```bash
37-
$ npm install winston
38-
$ npm install winston-stackify
39-
```
40-
41-
If you are already using Winston you should add the stackify transport module to your instance of Winston:
42-
```js
43-
require('winston-stackify').Stackify;
44-
winston.add(winston.transports.Stackify(options));
45-
```
46-
47-
All the details could be found here - [Winston Transport for Stackify](https://github.com/stackify/stackify-log-winston)
48-
4934
#### Using direct logger
5035

5136
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:
5237
```js
53-
stackify.log(level, message [, meta1, ... , metaN])
54-
stackify.trace(message [, meta1, ... , metaN])
55-
stackify.debug(message [, meta1, ... , metaN])
56-
stackify.info(message [, meta1, ... , metaN])
57-
stackify.warn(message [, meta1, ... , metaN])
58-
stackify.error(message [, meta1, ... , metaN])
38+
stackify.log(level, message [, meta])
39+
stackify.trace(message [, meta])
40+
stackify.debug(message [, meta])
41+
stackify.info(message [, meta])
42+
stackify.warn(message [, meta])
43+
stackify.error(message [, meta])
5944
```
6045

6146
**Message** must be a string.
6247

63-
**meta1 ... metaN** - a list of additional parameters of any type.
48+
**meta** - an additional parameter of any type.
6449

6550
Examples of usage:
6651
```js

lib/helpers.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ var stackTrace = require('stack-trace'),
1111
*/
1212

1313
module.exports.parseMeta = function parseMeta(meta, err) {
14-
var result = {
15-
'arguments': []
16-
},
17-
ex;
14+
15+
var result = null;
16+
var ex;
1817

1918
meta.forEach(function (elem) {
2019
var prop;
@@ -28,18 +27,15 @@ module.exports.parseMeta = function parseMeta(meta, err) {
2827
}
2928
}
3029
if (Object.keys(elem).length) {
31-
result['arguments'].push(elem);
30+
result = JSON.stringify(elem);
3231
}
3332
} else if (elem instanceof Error && err && !ex) {
3433
ex = elem;
3534
} else {
36-
result['arguments'].push(elem);
35+
result = JSON.stringify({"logArg":elem});
3736
}
3837
});
3938

40-
41-
result = result['arguments'].length ? JSON.stringify(result) : null;
42-
4339
return {
4440
result: result,
4541
ex: ex

0 commit comments

Comments
 (0)