Skip to content

Commit d8e0a79

Browse files
committed
updated readme
1 parent 7b0d2bb commit d8e0a79

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,51 @@ logstash.send(message [, callback]);
3030

3131
## API
3232

33+
### Constructor
34+
35+
Takes the following parameters:
36+
* **type**: type of connection, currently supported tcp, udp, memory
37+
* **host**: remote hostname
38+
* **port**: remote port
39+
* **format** (optional): formatter function (by default the message gets JSON.stringified)
40+
41+
Example:
42+
3343
```js
3444
new Client({
35-
type: 'type of connection, currently supported tcp, udp, memory',
36-
host: 'target host',
37-
port: 'target port',
38-
format: '<custom formatter function>'
45+
type: 'tcp',
46+
host: 'logstash.example.org',
47+
port: 8099,
48+
format: function(message) {
49+
message.formattedAt = new Date();
50+
message.password = '!FILTERED!';
51+
return JSON.stringify(message, null, 2);
52+
}
53+
});
54+
```
55+
56+
### Client#send
57+
58+
Takes the following parameters:
59+
60+
* **message**: an object what you are trying to send to your logstash instance
61+
* **callback** (optional): a function called when the message has been sent
62+
63+
Example:
64+
65+
```js
66+
var client = new Client({
67+
type: 'tcp',
68+
host: 'example.org',
69+
port: 1337
70+
});
71+
client.send({
72+
'@timestamp': new Date(),
73+
'message': 'Important',
74+
'level': 'error'
3975
});
4076
```
77+
4178
## License
4279

4380
MIT

0 commit comments

Comments
 (0)