const graylog2 = require("graylog2");

const logger = new graylog2.graylog({
  servers: [{ host: "logs.bodyshop.app", port: 12201 }]
});

function log(message, type, user, record, object) {
  if (type !== "ioevent")
    console.log(message, {
      type,
      env: process.env.NODE_ENV || "development",
      user,
      record,
      ...object
    });
  logger.log(message, message, {
    type,
    env: process.env.NODE_ENV || "development",
    user,
    record,
    ...object
  });
}

module.exports = { log };
