Skip to main content

日志器

Playwright 生成大量日志,并且可以通过插件化日志器接收器访问它们。

Playwright generates a lot of logs and they are accessible via the pluggable logger sink.

const { chromium } = require('playwright');  // Or 'firefox' or 'webkit'.

(async () => {
const browser = await chromium.launch({
logger: {
isEnabled: (name, severity) => name === 'browser',
log: (name, severity, message, args) => console.log(`${name} ${message}`)
}
});
// ...
})();

方法

Methods

isEnabled

Added in: v1.8 logger.isEnabled

确定接收器是否对具有给定名称和严重性的日志器感兴趣。

Determines whether sink is interested in the logger with the given name and severity.

用法

Usage

logger.isEnabled(name, severity);

参数

Arguments

日志器名称

logger name

  • severity "verbose"|"info"|"warning"|"error"#

返回

Returns


log

Added in: v1.8 logger.log

用法

Usage

logger.log(name, severity, message, args, hints);

参数

Arguments

日志器名称

logger name

  • severity "verbose"|"info"|"warning"|"error"#

日志消息格式

log message format

消息参数

message arguments

可选的首选日志器颜色。

Optional preferred logger color.

可选格式提示

optional formatting hints