(label: string)
| 40 | }); |
| 41 | |
| 42 | const createLogger = (label: string) => { |
| 43 | const isStructuredLoggingEnabled = env.SOURCEBOT_STRUCTURED_LOGGING_ENABLED === 'true'; |
| 44 | |
| 45 | return winston.createLogger({ |
| 46 | level: env.SOURCEBOT_LOG_LEVEL, |
| 47 | format: combine( |
| 48 | errors({ stack: true }), |
| 49 | timestamp(), |
| 50 | labelFn({ label: label }), |
| 51 | ), |
| 52 | transports: [ |
| 53 | new winston.transports.Console({ |
| 54 | format: isStructuredLoggingEnabled |
| 55 | ? combine( |
| 56 | datadogFormat(), |
| 57 | json() |
| 58 | ) |
| 59 | : combine( |
| 60 | colorize(), |
| 61 | humanReadableFormat |
| 62 | ), |
| 63 | }), |
| 64 | ...(env.SOURCEBOT_STRUCTURED_LOGGING_FILE && isStructuredLoggingEnabled ? [ |
| 65 | new winston.transports.File({ |
| 66 | filename: env.SOURCEBOT_STRUCTURED_LOGGING_FILE, |
| 67 | format: combine( |
| 68 | datadogFormat(), |
| 69 | json() |
| 70 | ), |
| 71 | }), |
| 72 | ] : []), |
| 73 | ...(env.LOGTAIL_TOKEN && env.LOGTAIL_HOST ? [ |
| 74 | new LogtailTransport( |
| 75 | new Logtail(env.LOGTAIL_TOKEN, { |
| 76 | endpoint: env.LOGTAIL_HOST, |
| 77 | }) |
| 78 | ) |
| 79 | ] : []), |
| 80 | ] |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | export { |
| 85 | createLogger |
no outgoing calls
no test coverage detected