Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @midwayjs/logger

References

DelegateLoggerOptions

DelegateLoggerOptions:

DelegateTransport

DelegateTransport:

DelegateTransportOptions

DelegateTransportOptions:

EmptyLogger

EmptyLogger:

EmptyTransport

EmptyTransport:

ILogger

ILogger:

IMidwayLogger

IMidwayLogger:

LoggerCustomInfoHandler

LoggerCustomInfoHandler:

LoggerLevel

LoggerLevel:

LoggerOptions

LoggerOptions:

MidwayBaseLogger

MidwayBaseLogger:

MidwayContextLogger

MidwayContextLogger:

MidwayDelegateLogger

MidwayDelegateLogger:

MidwayTransformableInfo

MidwayTransformableInfo:

displayCommonMessage

displayCommonMessage:

displayLabels

displayLabels:

format

format:

transports

transports:

Type aliases

ContainerCoverMethodName

ContainerCoverMethodName: "disableConsole" | "disableFile" | "disableError" | "updateLevel" | "updateConsoleLevel" | "updateFileLevel"

LoggerCustomInfoHandler

LoggerCustomInfoHandler: function

LoggerLevel

LoggerLevel: "silly" | "debug" | "info" | "warn" | "error"

Variables

Const EmptyLogger

EmptyLogger: Logger = createLogger().constructor as Logger

LEVEL

LEVEL: any

MESSAGE

MESSAGE: any

SPLAT

SPLAT: any

TransportStream

TransportStream: TransportStream

Const displayCommonMessage

displayCommonMessage: FormatWrap = format((info,opts: {defaultLabel?: string;defaultMeta?: Record<string, unknown>;target?: IMidwayLogger;}) => {if (!info.pid) {info.pid = process.pid;}if (!info.ignoreFormat) {info.ignoreFormat = false;}if (!info.ctx) {info.ctx = null;}if (!info.LEVEL) {info.LEVEL = info.level.toUpperCase();}if (!info.defaultLabel) {info.defaultLabel =opts.defaultLabel || opts.target?.getDefaultLabel() || '';}if (info instanceof Error) {// 参数只是 error 的情况return Object.assign({level: info.level,[LEVEL]: info[LEVEL] || info['level'],message: info.stack,[MESSAGE]: info[MESSAGE] || info.stack,originError: info,stack: info.stack,pid: info.pid,LEVEL: info.LEVEL,defaultLabel: info.defaultLabel,ignoreFormat: info.ignoreFormat,ctx: null,},opts.defaultMeta || opts.target?.getDefaultMeta() || {});}// error(new Error(''), {label: 1}) 的情况if (info.message['stack'] && info.message['message']) {const err = new Error(info.message['message']);err.name = info.message['name'];err.stack = info.message['stack'];info.originError = err;info.stack = info.message['stack'];info.message = err.stack;info[MESSAGE] = info[MESSAGE] || info.message;}// 处理数组,Map,Set 的 messageif (Array.isArray(info.message) ||types.isSet(info.message) ||types.isMap(info.message)) {info.message = inspect(info.message);}// error 参数在最后的情况if (info[SPLAT] && info[SPLAT].length > 0) {// 目前只会有一个 error,只会在最后一个参数const err = info[SPLAT][info[SPLAT].length - 1];if (err instanceof Error) {info.message = info.message.replace(err.message, '') + err.stack;info[MESSAGE] = info[MESSAGE] || info.message + err.stack;info.originError = err;info.stack = err.stack;}}return Object.assign(info,opts.defaultMeta || opts.target?.getDefaultMeta() || {});})

Const displayLabels

displayLabels: FormatWrap = format((info, opts) => {opts.labelSplit = opts.labelSplit || ':';info.labelText = joinLoggerLabel(opts.labelSplit,info.defaultLabel,...[].concat(info.label));return info;})

Const isWindows

isWindows: boolean = os.platform() === 'win32'

Const loggers

loggers: MidwayLoggerContainer = new MidwayLoggerContainer()

Functions

Const clearAllLoggers

  • clearAllLoggers(): void

Const createConsoleLogger

Const createFileLogger

Const createLogger

joinLoggerLabel

  • joinLoggerLabel(labelSplit: any, ...labels: any[]): string

Object literals

Const midwayLogLevels

midwayLogLevels: object

all

all: number = 0

debug

debug: number = 5

error

error: number = 1

info

info: number = 3

silly

silly: number = 6

verbose

verbose: number = 4

warn

warn: number = 2

Const statusMapping

statusMapping: object

数组结构为获取当前的状态值 + 恢复状态值的方法

disableConsole

disableConsole: string[] = ['isEnableConsole', 'enableConsole']

disableError

disableError: string[] = ['isEnableError', 'enableError']

disableFile

disableFile: string[] = ['isEnableFile', 'enableFile']

updateConsoleLevel

updateConsoleLevel: string[] = ['getConsoleLevel', 'updateConsoleLevel']

updateFileLevel

updateFileLevel: string[] = ['getFileLevel', 'updateFileLevel']

updateLevel

updateLevel: string[] = ['getLevel', 'updateLevel']

Generated using TypeDoc