Socket
Book a DemoInstallSign in
Socket

winston-web-transport

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-web-transport

This is a transport for winston which logs to a web server.

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

Winston web transport

This is a transport for winston which logs to a web server.

Thubmnail

Installation

npm install winston-web-transport

Usage

import winston from "winston"
import WebTransport from "../src/main"
import { join } from "path"

export function createLogger() {
    const logger = winston.createLogger({
        format: winston.format.combine(
            winston.format.prettyPrint(),
            winston.format.errors(),
            winston.format.colorize(),
            winston.format.timestamp({
                format: "YYYY-MM-DD HH:mm:ss"
            }),
            winston.format.printf(
                (info) =>
                    `[${info.timestamp}] [${info.level}]: ${info.message}` +
                    (info.splat !== undefined ? `${info.splat}` : " ")
            )
        ),

        exitOnError: false,
        handleExceptions: true,
        handleRejections: true,

        transports: [
            /*
            {
                port: number
                password?: string
                dateFormat?: string

                sqlite?: {
                    filepath: string
                    table: string

                    paginationnDate?: Date
                    paginationnLimit?: number

                    logVersion?: string
                }

                postgres?: {
                    connectionUri: string
                    table: string

                    paginationnDate?: Date
                    paginationnLimit?: number

                    rejectUnauthorized?: boolean

                    logVersion?: string
                }
            }
            */
            new WebTransport({
                port: 3000,
                password: "123",
                sqlite: {
                    filepath: join(__dirname, "logs.db"),
                    table: "logs"
                }
            })
        ]
    })

    return logger
}

const logger = createLogger()
setInterval(() => {
    logger.info("Hello, world!")
}, 5000)

FAQs

Package last updated on 06 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts