winston#Logger TypeScript Examples

The following examples show how to use winston#Logger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: logging.ts    From Assistive-Webdriver with MIT License 6 votes vote down vote up
export function createDefaultLogger(): Logger {
  return createLogger({
    format: format.combine(
      format.timestamp(),
      format.colorize(),
      messageId(),
      defaultFormatter
    ),
    transports: [new transports.Console()]
  });
}
Example #2
Source File: index.ts    From denote-md-backend with MIT License 6 votes vote down vote up
private core: Logger;
Example #3
Source File: ActionFactory.ts    From context-mod with MIT License 6 votes vote down vote up
export function actionFactory
(config: StructuredActionJson, logger: Logger, subredditName: string, resources: SubredditResources, client: ExtendedSnoowrap, emitter: EventEmitter): Action {
    switch (config.kind) {
        case 'comment':
            return new CommentAction({...config as StructuredFilter<CommentActionJson>, logger, subredditName, resources, client, emitter});
        case 'lock':
            return new LockAction({...config as StructuredFilter<LockActionJson>, logger, subredditName, resources, client, emitter});
        case 'remove':
            return new RemoveAction({...config as StructuredFilter<RemoveActionJson>, logger, subredditName, resources, client, emitter});
        case 'report':
            return new ReportAction({...config as StructuredFilter<ReportActionJson>, logger, subredditName, resources, client, emitter});
        case 'flair':
            return new FlairAction({...config as StructuredFilter<FlairActionJson>, logger, subredditName, resources, client, emitter});
        case 'userflair':
            return new UserFlairAction({...config as StructuredFilter<UserFlairActionJson>, logger, subredditName, resources, client, emitter});
        case 'approve':
            return new ApproveAction({...config as StructuredFilter<ApproveActionConfig>, logger, subredditName, resources, client, emitter});
        case 'usernote':
            return new UserNoteAction({...config as StructuredFilter<UserNoteActionJson>, logger, subredditName, resources, client, emitter});
        case 'ban':
            return new BanAction({...config as StructuredFilter<BanActionJson>, logger, subredditName, resources, client, emitter});
        case 'message':
            return new MessageAction({...config as StructuredFilter<MessageActionJson>, logger, subredditName, resources, client, emitter});
        case 'dispatch':
            return new DispatchAction({...config as StructuredFilter<DispatchActionJson>, logger, subredditName, resources, client, emitter});
        case 'cancelDispatch':
            return new CancelDispatchAction({...config as StructuredFilter<CancelDispatchActionJson>, logger, subredditName, resources, client, emitter})
        case 'contributor':
            return new ContributorAction({...config as StructuredFilter<ContributorActionJson>, logger, subredditName, resources, client, emitter})
        default:
            throw new Error('rule "kind" was not recognized.');
    }
}
Example #4
Source File: endpoint.ts    From express-zod-api with MIT License 6 votes vote down vote up
async #runMiddlewares({
    input,
    request,
    response,
    logger,
  }: {
    input: any;
    request: Request;
    response: Response;
    logger: Logger;
  }) {
    const options: any = {};
    let isStreamClosed = false;
    for (const def of this.middlewares) {
      Object.assign(input, await def.input.parseAsync(input)); // middleware can transform the input types
      Object.assign(
        options,
        await def.middleware({
          input,
          options,
          request,
          response,
          logger,
        })
      );
      isStreamClosed = "writableEnded" in response && response.writableEnded;
      if (isStreamClosed) {
        logger.warn(
          `The middleware ${def.middleware.name} has closed the stream. Accumulated options:`,
          options
        );
        break;
      }
    }
    return { input, options, isStreamClosed };
  }
Example #5
Source File: errorMiddleware.ts    From TXQ with MIT License 6 votes vote down vote up
handle404Error = (router: Router) => {
  router.use((req: Request, res: Response) => {
    const logger: Logger = Container.get('logger');
    logger.error('404', {
      method: req.method,
      url: req.originalUrl,
      query: req.query,
      ip: req.ip,
    });
    res.status(404);
    res.api.errors.push({
      field: 'endpoint',
      message: 'API endpoint does not exist',
    });
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Headers', 'Content-Type,api_key');
    res.header('Access-Control-Allow-Methods', 'POST,GET,HEAD,DELETE,OPTIONS');
    res.api.status = 404;
    res.json(res.api);
  });
}
Example #6
Source File: CacheManager.ts    From backstage with Apache License 2.0 6 votes vote down vote up
private constructor(
    store: string,
    connectionString: string,
    logger: Logger,
    errorHandler: CacheManagerOptions['onError'],
  ) {
    if (!this.storeFactories.hasOwnProperty(store)) {
      throw new Error(`Unknown cache store: ${store}`);
    }
    this.logger = logger;
    this.store = store as keyof CacheManager['storeFactories'];
    this.connection = connectionString;
    this.errorHandler = errorHandler;
  }
Example #7
Source File: WinstonLogger.ts    From ExpressLRS-Configurator with GNU General Public License v3.0 5 votes vote down vote up
constructor(private readonly logger: Logger) {}
Example #8
Source File: index.ts    From context-mod with MIT License 5 votes vote down vote up
logger: Logger;