@acteam-it/winston-socket.io 中文文档教程
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
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" }));
更多
你可能也喜欢
- 97gg-home-test 中文文档教程
- @0y0/webpack-config-react 中文文档教程
- @1coinswap/sushi1coin-sdk 中文文档教程
- @3sidedcube/prettier-config 中文文档教程
- @7rabbit/wood 中文文档教程
- @97kid/sso-react 中文文档教程
- @aarhus-university/au-app-react-election 中文文档教程
- @absinthe-noarrows/socket 中文文档教程
- @ace_tao/vue 中文文档教程
- @achievewithoutborders/file-upload-client 中文文档教程