You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, my quick solution with typings was to merge the interfaces as follows
import * as winston from "winston";
import {Transports} from "winston/lib/winston/transports";
import {SyslogTransportInstance} from "winston-syslog";
require('winston-syslog').Syslog;
/** hacking types for injected syslog transport :( */
const winstonTransports = winston.transports as Transports & {Syslog: SyslogTransportInstance};
then just refer to typed winstonTrasports ie. add(new winstonTransports.Syslog())
import{createLogger}from'winston';import{SyslogTransportOptions,Syslog}from'winston-syslog';constopt: SyslogTransportOptions={host: 'localhost',port: 1234,protocol: 'tcp4',facility: 'local0',app_name: 'My App',eol: '\n'};// and then either this way:constlogger=createLogger({levels: winston.config.syslog.levels});consttransport=newSyslog(opt);logger.add(transport);// or this way:constlogger=createLogger({levels: winston.config.syslog.levels,tranports: [newSyslog(opt)]});
Hello there,
Does winston-syslog support typescript? I see there are is a
@types/winston-syslog
but I can't seem to get it working.In my package.json I have
and am trying to run:
and get back
Property 'Syslog' does not exist on type 'Transports'.
I can run
as described in the documentation, but then I lose all type definitions and all of winston/winston-syslog is typed as "any"
I see an issue was previously opened in the winston repo, and the suggestion was to direct the question here so I figured I'd ask here.
Thanks so much for your help!
The text was updated successfully, but these errors were encountered: