Skip to content

Http Transport uses JSON format options as request options #1732

Closed
@MoritzLoewenstein

Description

@MoritzLoewenstein

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • _node -v outputs: v13.1.0
  • _Operating System? windows & linux same behaviour
  • _Language? -

What is the problem?

If I use a property in a JSON formatted log which has the same name as an option in the configuration of the Http Transport its used as an option there (See Example Code).

What do you expect to happen instead?

I do expect that the contents of <logger>.log() directly go the logging transport and do not interfere with the transport configuration.

Example Code

const winston = require("winston");
const express = require("express");

const app = express();

app.post("/a", (req, res) => {
  console.log("This is good");
});

app.post("/b", (req, res) => {
  console.log("This is bad");
});

app.listen(80, console.log("Server started"));

const logger = winston.createLogger({
  format: winston.format.json(),
  transports: [
    new winston.transports.Http({
      host: "localhost",
      path: "/a"
    })
  ]
});

logger.log({ message: "abc", level: "info", path: "/b" });

Example Code Output

Server started
This is bad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions