nlf / bucker

A simple logging library for node.js
82 stars 28 forks source link

Teach logStash to accept static key/values from the config file #30

Closed cjthompson closed 2 years ago

cjthompson commented 10 years ago

This PR gives the logstash writer the ability to write a static list of key-value pairs to each log entry. This allows for custom configuration file to be written on different servers/environments that will contain static data to log, such as the server name, ip address, or other important server-specific information.

One way to leverage this change is to use the npm config module with a default bucker configuration section and override that using a separate config per environment and server.

{
    "logstash": {
        "static_keys": {
            "hostname": "host.domain.com",
        }
    }
}
nlf commented 10 years ago

Working on a major refactor/rewrite of all the code right now, but I feel like we could use tags for this rather than adding a transport specific config item.. Just a quick check for if tags is an object in the logstash transport should be plenty, no?

cjthompson commented 10 years ago

Perhaps, if you define tags in the configuration so that certain tags will always be outputted.

nlf commented 10 years ago

As is, you can do

var logger = require('bucker').createLogger(/* opts */).tags(/* tags */);

and you'll get the same effect

nlf commented 10 years ago

I am working on the rewrite though, so if you have other ideas, now is a good time to bring them up

glock47 commented 2 years ago

https://github.com/nlf/bucker/pull/30#issuecomment-46035928