@acteam-it/winston-socket.io 中文文档教程

发布于 4年前 浏览 18 项目主页 更新于 3年前

winston-socket.io

构建状态 依赖状态

一个 socket.io winstonjs 的传输。 使您能够直接登录到 socket.io 服务器。

有关更多使用详细信息,请参阅示例文件夹。

Options

  • host: The hostname of the socket.io server (default: http://localhost).
  • port: The port of the socket.io server (default: 3000).
  • secure: Use https for the socket.io server connection (default: false).
  • reconnect: Reconnect to socket.io server connection (default: false).
  • namespace: The socket.io namespace to use for the logs (default: "log").
  • log_topic: The topic to send the log messages on (default: "log").
  • encrypt: Choose to encrypt winston socket logs or not (default: false)
  • secret: the passphrase to encrypt logs with [needs encrypt to be true to allow changing it ] (default: null)
  • log_format: The format in which to log the information.
  • maxqueuesize: The maximum number of messages to queue up for publishing if the client isnt connected to the server (default: 1000).

How to use it

  const winston = require('winston');
  require('winston-socket.io');

  let logger = winston.createLogger({
    level: "info",
    transports: [
      new winston.transports.Console(),
      new winston.transports.SocketIO(
        {
          host: "http://myhost",
          port: 8080
          secure: true,
          reconnect: true,
          namespace: "log",
          log_topic: "log"
        }
      )
    ]
  });  

  logger.log("info", "I'm logging to the socket.io server!!!");
  logger.log("info", "I'm logging something else", {meta: "some additional info"});

也可以在这个方法中作为传输添加到 Winston

``` js

const winston = require('winston'); require('winston-socket.io');

winston.add(新的 winston.transports.SocketIO({ 主机:“http://myhost”, 端口:8080 安全:真实, 重新连接:是的, 命名空间:“日志”, 日志主题:“日志” }));

winston-socket.io

Build Status Dependency Status

A socket.io transport for winstonjs. Gives you the ability to log directly to a socket.io server.

See the examples folder for more usage details.

Options

  • host: The hostname of the socket.io server (default: http://localhost).
  • port: The port of the socket.io server (default: 3000).
  • secure: Use https for the socket.io server connection (default: false).
  • reconnect: Reconnect to socket.io server connection (default: false).
  • namespace: The socket.io namespace to use for the logs (default: "log").
  • log_topic: The topic to send the log messages on (default: "log").
  • encrypt: Choose to encrypt winston socket logs or not (default: false)
  • secret: the passphrase to encrypt logs with [needs encrypt to be true to allow changing it ] (default: null)
  • log_format: The format in which to log the information.
  • maxqueuesize: The maximum number of messages to queue up for publishing if the client isnt connected to the server (default: 1000).

How to use it

  const winston = require('winston');
  require('winston-socket.io');

  let logger = winston.createLogger({
    level: "info",
    transports: [
      new winston.transports.Console(),
      new winston.transports.SocketIO(
        {
          host: "http://myhost",
          port: 8080
          secure: true,
          reconnect: true,
          namespace: "log",
          log_topic: "log"
        }
      )
    ]
  });  

  logger.log("info", "I'm logging to the socket.io server!!!");
  logger.log("info", "I'm logging something else", {meta: "some additional info"});

Can also be added to Winston as a transport in this method

``` js

const winston = require('winston'); require('winston-socket.io');

winston.add(new winston.transports.SocketIO({ host: "http://myhost", port: 8080 secure: true, reconnect: true, namespace: "log", log_topic: "log" }));

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文