Commit 77e46af2 authored by Félix Hamel's avatar Félix Hamel

+ Add LogDNA hostname support

parent 6bc9a2f7
......@@ -21,17 +21,34 @@ var P = require("bluebird"),
Hapi = require("hapi"),
bformat = require("bunyan-format"),
Injector = require("./injector"),
_ = require("lodash");
_ = require("lodash"),
os = require('os');
// Prepare logs
/// If we don't have the LogDNA key, we don't use it
var streams = [
{
level: "info",
stream: process.stdout // log INFO and above to stdout
}
];
// Prepare LogDNA configuration
if (process.env.LOGDNA_KEY) {
if (typeof process.env.LOGDNA_KEY !== "undefined") {
var LogDNAStream = require("logdna-bunyan").BunyanStream;
var logDNA = new LogDNAStream({
key: process.env.LOGDNA_KEY,
app: process.env.LOGDNA_APP_NAME || "core",
env: process.env.LOGDNA_ENV || "local",
level: process.env.LOGDNA_LEVEL || "info"
level: process.env.LOGDNA_LEVEL || "info",
hostname: process.env.LOGDNA_HOSTNAME || os.hostname()
});
streams.push({
stream: logDNA,
type: "raw"
});
}
function CMBF() {
......@@ -40,21 +57,6 @@ function CMBF() {
this.plugins = [];
this.hooks = {};
this.injector = new Injector();
// Prepare logs
/// If we don't have the LogDNA key, we don't use it
var streams = [
{
level: "info",
stream: process.stdout // log INFO and above to stdout
}
];
if (typeof process.env.LOGDNA_KEY !== "undefined") {
streams.push({
stream: logDNA,
type: "raw"
});
}
this.log = bunyan.createLogger({
name: "core",
level: process.env.SYSTEM_LOG_LEVEL || "info",
......@@ -517,21 +519,6 @@ CMBF.prototype.launch = P.method(function(pluginOpts) {
"Loading default foundation plugins: hapi-bunyan",
availablePlugins
);
// Prepare streams
var streams = [
{
level: "info",
stream: process.stdout // log INFO and above to stdout
}
];
if (typeof process.env.LOGDNA_KEY !== "undefined") {
streams.push({
stream: logDNA,
type: "raw"
});
}
return registerPlugin({
register: require("hapi-bunyan"),
options: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment