Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colors are not being stripped from messages and metadata anymore #88

Open
nicobleiler opened this issue Apr 23, 2024 · 0 comments
Open

Comments

@nicobleiler
Copy link

#18 seems to have been broken along the way.

require('dotenv').config();
const winston = require('winston');
const LogstashTransport = require("winston-logstash/lib/winston-logstash-latest");
const os = require('os');

// Prepare logging
const logger = winston.createLogger({
    level: "debug",
    format: winston.format.combine(winston.format.simple(), winston.format.timestamp(), winston.format.colorize()),
    defaultMeta: {
        environment: process.env.NODE_ENV || "development",
        service: 'ephemeral',
        host: os.hostname(),
        version: require('./package.json').version,
    },
    transports: [
        new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
        new winston.transports.File({ filename: 'logs/combined.log' }),
        new winston.transports.Console(),
    ],
});

if (process.env.LOGSTASH_HOST && process.env.LOGSTASH_PORT && process.env.LOGSTASH_HOST) {
    logger.info("Using Logstash");
    logger.add(        
        new LogstashTransport({
            port: process.env.LOGSTASH_PORT,
            node_name: process.env.LOGSTASH_NODE_NAME,
            host: process.env.LOGSTASH_HOST,
            max_connect_retries: -1
        }),
    );
} else {
    logger.info("Missing ENV variables to use Logstash");
}

module.exports = {
    logger: logger
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant