Skip to main content

Configuration

Two option fixtures configure the loggers. Both are optional and flat objects.

playwright.config.ts
import { defineConfig } from '@playwright/test';
import type { LoggerOptions } from 'playwright-logger-pro/fixtures';

export default defineConfig<LoggerOptions>({
use: {
apiLog: { curl: 'on-failure' },
browserLog: { network: 'failed', redact: { values: [process.env.E2E_PASSWORD].filter((v): v is string => !!v) } },
},
});
Documentation is checked against the code

The option tables on this page are compared with the library's option types and exported defaults when the site is built (npm run check-config in website/). A missing or extra option, or a wrong default, fails the build.

Precedence and merge rules​

  • test.use() replaces the whole object. test.use({ apiLog: { curl: true } }) replaces the apiLog from your config; it does not merge. Repeat the options you still want. The same holds for browserLog.
  • redact is merged one level deep with the defaults: setting redact: { values: [...] } keeps the default selectors, keys and the rest. Setting redact.selectors or redact.keys adds to the defaults; apiLog.replaceDefaultRedaction: true replaces them.
  • undefined means the default. An option explicitly set to undefined uses its default, which lets you write colors: process.env.CI ? true : undefined.
  • Explicit colors wins over every colour environment variable.
  • Invalid values never throw. An unknown option or invalid value prints a one-time [playwright-logger-pro] warning naming the option, and the default is used. (maxEvents must be a positive integer so a bad value can never switch the failure block off.)
  • httpCredentials arrays. Playwright reads test.use({ httpCredentials: [a, b] }) as [value, options], not as two credentials. To pass an array, write test.use({ httpCredentials: [[a, b], { scope: 'test' }] }).
  • Redaction lists are merged with the built-in lists, in apiLog and in browserLog's redact; see replaceDefaultRedaction, the one switch that drops the defaults of both.

apiLog options​

Configures request logging for the request fixture and wrapRequestContext().

OptionTypeDefaultDescription
enabledbooleantruefalse makes the wrapper a transparent pass-through.
colorsbooleanautotrue/false force ANSI colours on/off (true wins over NO_COLOR). In compact output an explicit value also decides the colours of the reporter (it reads it from the JSON attachment; the reporter's own colors wins). Auto: see Environment variables. With a custom sink and no explicit colors, auto means off, so ANSI codes do not reach a file.
format'compact' | 'verbose''compact''compact': one line per call and detail only where something went wrong, printed by the reporter. 'verbose': the 0.3 output (request, headers, bodies, response, curl) printed live.
curlboolean | 'on-failure' | '5xx' | '4xx+' | 'always' | 'never''5xx'Which calls get a curl (and a curl.sh attachment): '5xx' status >= 500 and network errors, '4xx+' status >= 400 and network errors, 'always' (every call gets a curl in the playwright-logger-pro.json attachment; its curl*.sh script is attached only for a failed test or with details: 'always'; the compact console still prints curls only under failed calls, status >= 400 or a network error), 'never'. Legacy: true is 'always', false is 'never', 'on-failure' is '4xx+' in compact output (the console shows curls for status >= 400 and network errors; a 1xx/3xx response also gets its curl*.sh when the test failed) and any non-2xx with format: 'verbose'. With format: 'verbose' the default is false, as in 0.3. Other values warn and use the default. To also get the curl of a successful call whose test failed, see curlOnFailedTest.
curlOnFailedTestfalse | true | 'last' | 'all'falseCompact output. When a test fails, the curl and a curl.sh of the last call made before the failure ('last', same as true) or of every call made before it ('all'), whatever its status, shown in a neutral │ block under its line; the status chip keeps its success colour. Masked like every curl (*** on the console, ${VAR} placeholders in curl.sh). Independent of curl (works with curl: 'never'); details: 'never' leaves the block out and curlFormat.file: false the file. Calls made after the first failure (an afterEach cleanup, steps after a failed expect.soft) are never the last call. Does nothing for a passing test. See Compact output.
slowThresholdMsnumber1000A call at least this slow gets ▲ and a yellow time, and counts in the footer.
timeColumnnumber | 'auto'82Column where the timing ends. 'auto' fits the terminal width. A longer line keeps a 2-space gap and, past the terminal width, loses the middle of its query string.
details'failed-tests' | 'always' | 'never''failed-tests'When a request with status >= 400 or a network error gets its │ block: only when its test failed, always, or never.
bodyPreviewCharsnumber200Length of the response body preview in the block, in characters.
theme'ansi' | 'dark' | 'light''ansi''ansi' uses the 16 basic colours of your terminal theme. 'dark' and 'light' are true-colour palettes (the ones of the README screenshots).
asciibooleanfalse (true on legacy Windows consoles)ASCII symbols (| <- ^ -> ok x) instead of Unicode.
mask{ headers?, query?, bodyKeys? }{}Extra names to mask, merged with the built-in lists and with redactHeaders, redactQueryParams and redactBodyKeys. The mask is always ***.
curlFormat{ colors?, multiline?, file? }{ colors: 'auto', multiline: true, file: true }How the curl is printed and saved: colours, single-line output and the curl.sh file. See curlFormat.
logHeadersbooleantrueLog request and response headers (compact: keep them in the JSON attachment).
logBodybooleantrueLog request and response bodies (compact: keep them in the JSON attachment and show the response preview).
maxBodyLengthnumber2000Truncate logged bodies beyond this many characters. A number ≥ 0; Infinity disables truncation. Applies to format: 'verbose' and the JSON attachment; the compact curl is cut at 2 KB.
redactHeadersstring[][] plus the built-in authorization, proxy-authorization, cookie, set-cookie, x-api-key, x-auth-tokenExtra header names masked in logs and curl. Case-insensitive; merged with the defaults.
redactQueryParamsstring[][] plus the built-in api_key, apikey, token, access_token, refresh_token, key, password, secret, signature, sigExtra query parameter names masked in logged URLs and curl. Merged with the defaults.
redactBodyKeysstring[][] plus the built-in password, token, accessToken, refreshToken, secret, apiKey, cardToken, cardNumber, cvv, pin, access_token, refresh_token, api_key, card_numberExtra JSON/form body keys and multipart field names masked in logged bodies and curl, at any depth.
replaceDefaultRedactionbooleanfalsetrue drops the built-in lists: only your lists are used, and a list you leave out redacts nothing. Also applies to browserLog.redact (selectors, keys, queryParams, headers). Dangerous.
sink(line: string) => voidconsole.logWhere log lines go. A throwing sink warns once and falls back to console.log.
baseURLstringfixture: use.baseURLUsed to show absolute URLs and the original URL of redirected requests. The fixture fills it in; pass it yourself with wrapRequestContext().
extraHTTPHeadersRecord<string, string>fixture: use.extraHTTPHeadersHeaders the context sends with every request, shown in logged headers and curl. The fixture fills it in; with wrapRequestContext() pass the headers you gave newContext().

curlFormat​

Presentation of the curl command. Only the printed command changes; the redaction is the same everywhere. An invalid value warns once and uses the default.

OptionTypeDefaultDescription
colorsboolean | 'auto''auto'Colours the curl and, with format: 'compact', the whole output printed by the fixture (without the reporter). 'auto' colours only when NO_COLOR is unset, the process is not on CI, the output is a terminal (stdout is a TTY, the test runner's own stdout is one, or PLAYWRIGHT_FORCE_TTY is set), the resolved colors is true and the sink is the default console one. A local npx playwright test in a terminal therefore colours it with no setting. FORCE_COLOR alone does not colour it in CI or when piped, and neither does a top-level colors: true for the verbose output. In compact output a top-level colors: true colours the whole output, the curl in the block included (see Compact output). true is an explicit override that skips all of these checks (ANSI codes may reach CI logs, files and custom sinks); false never colours. See When the curl is coloured.
multilinebooleantruefalse prints the command on a single line, options joined by single spaces. Notes and redirect step comments stay on their own # lines above it.
filebooleantrueWith the test fixture, attach the curls to the report as scripts. Compact: curl.sh (or curl-{n}-{METHOD}-{lastPathSegment}.sh), #!/usr/bin/env bash, ${VAR} placeholders for masked values. Verbose: one curl.sh (#!/bin/sh) and a one-line notice. Only applies while curl is enabled.

See API logging › curl output for the colours, the colouring rules and the curl.sh file.

Reporter options​

playwright-logger-pro/reporter takes the display options of apiLog (they win over what the fixture recorded) and one more. See Compact output.

OptionTypeDefaultDescription
slowThresholdMs, timeColumn, details, bodyPreviewChars, theme, asciias in apiLogSame meaning and defaults.
curl'5xx' | '4xx+' | 'always' | 'never'from apiLog.curlWhich calls show their curl. The fixture decides which calls carry one (apiLog.curl, and every failed call); this can only show fewer, or more of the failed ones.
colorsboolean | 'auto''auto'true forces colours on, false off. 'auto': the explicit colors of the test's apiLog, if it has one; otherwise no colours on CI, with NO_COLOR, FORCE_COLOR=0, TERM=dumb or when stdout is not a terminal.

browserLog options​

OptionTypeDefaultDescription
enabledbooleantruefalse: no patches, listeners or session for the test.
colorsbooleanautoColours for print only. Files and attachments are always plain text.
actionsbooleantrueInteractions and navigations (click, fill, goto, ...).
waitsbooleantruewaitFor*, locator.waitFor, waitForTimeout.
queriesbooleanfalseRead-only async calls (textContent, isVisible, count, ...). Results are never logged.
mouseMovesbooleanfalsemouse.move (noisy).
navigationbooleantrueMain-frame navigations, page open/close/popup/crash, dialogs, downloads.
browserConsolefalse | 'error' | 'warning' | 'info' | 'all''warning'Minimum console level to record.
pageErrorsbooleantrueUncaught page exceptions.
networkfalse | 'failed' | 'documents' | 'all'falseNetwork capture. 'failed' = request failures and status ≥ 400; 'documents' = document, xhr and fetch. Subscribing adds protocol traffic.
networkFilter(r: { url: string; method: string; resourceType: string }) => booleannoneExtra filter applied after network.
stepsboolean | 'auto''auto'test.step integration. 'auto' is on for Playwright ≥ 1.48. false turns it off.
includeApiLogbooleantrueCopy apiLog lines into the attachment and file (never printed twice).
logStartbooleanfalseAlso print a line when an action starts (needs print: true).
slowActionMsnumber1000Highlight actions slower than this many ms; JSONL gets slow: true. A number ≥ 0.
locationbooleanfalseAppend the call site in your spec, such as (login.spec.ts:14). Costs one stack capture per action.
maxArgLengthnumber200Truncate each rendered argument and console message. A positive integer or Infinity.
maxEventsnumber5000Ring buffer per test; the oldest events are dropped and a marker says how many. A positive integer.
redactBrowserRedactConfigsee belowSecret masking.
printboolean | 'on-failure''on-failure'Print to sink: live (true) or one block when the test failed.
attachboolean | 'on-failure''on-failure'Attach browser-log to the report.
attachFormat'text' | 'jsonl''text'Format of the attachment.
fileboolean | 'on-failure'falseWrite a per-test file.
fileFormat'text' | 'jsonl''text'Format of the file.
fileDirstringthe test's output directoryDirectory for per-test files. Never cleaned by the logger.
sink(line: string) => voidconsole.logWhere printed text goes.

browserLog.redact​

OptionTypeDefaultDescription
maskstring'***'Replacement for masked values.
fillValues'auto' | 'always' | 'never''auto'Masking of typed values. 'auto': when the target looks sensitive. 'always': every typed value. 'never': none (values still applies).
selectors(string | RegExp)[]DEFAULT_SENSITIVE_SELECTORSMatched against the target's description; strings are case-insensitive substrings. Added to the default list; apiLog.replaceDefaultRedaction: true replaces it. Text is also matched after splitting on camelCase, _ and -, for your own entries too.
valuesstring[][]Literal secrets masked everywhere, in addition to the ones collected automatically. Values shorter than 4 characters are ignored.
keys(string | RegExp)[]the sensitive key patternsObject keys masked inside arguments. Added to the default patterns; apiLog.replaceDefaultRedaction: true replaces them.
queryParamsstring[]apiLog's resolved list: api_key, apikey, token, access_token, refresh_token, key, password, secret, signature, sig plus your apiLog.redactQueryParamsExtra query parameter names, added to apiLog's redactQueryParams (defaults included). Their values are masked in every URL the browser log prints.
headersstring[]apiLog's resolved list: authorization, proxy-authorization, cookie, set-cookie, x-api-key, x-auth-token plus your apiLog.redactHeadersExtra header names, added to apiLog's redactHeaders (defaults included).
inspectInputTypebooleanfalseOpt-in DOM probe for type=password after a fill. One extra round trip per distinct field.

buildCurl options​

buildCurl(info, redactHeaderNames?, options?) is exported for building a curl yourself: info is a RequestInfo, the second argument lists header names to mask, and the third is CurlOptions:

OptionTypeDefaultDescription
redactQueryParamsreadonly string[]noneQuery parameter names whose values are masked in the URL.
redactBodyKeysreadonly string[]noneJSON/form body keys and multipart field names whose values are masked.
maxBodyLengthnumbernoneTruncate the request body (and each form/field value) beyond this many characters.
colorsbooleanfalseColour the command with ANSI codes. Removing the codes gives exactly the uncoloured command.
colorDepth4 | 8detectedPalette used with colors: 8 for the 256-colour palette (38;5;N), 4 for the 16 basic colours. Detected from COLORTERM, TERM and the terminal when omitted. See API logging › Colours.
multilinebooleantrueOne option per line with \ continuations; false gives a single line.
maskstring | (key: string) => string'***'What replaces a masked value; a function receives the header, query parameter or body key name (the curl.sh attachment uses it for ${NAME} placeholders). Do not combine a function with colors.
skipHeadersreadonly string[]noneHeader names (case-insensitive) left out of the command.
truncationMarkerstringnoneAppended to a body cut by maxBodyLength.
truncationNote(limit, total) => stringbuilt-in noteText of the # note that announces a cut body.

Fixtures and exports​

From playwright-logger-pro/fixtures:

NameTypeDescription
testTestTypeDrop-in replacement for Playwright's test: wraps request and records browser actions. Adds the apiLog and browserLog option fixtures and the browserLogger fixture.
expectExpectPlaywright's expect, re-exported.
mergeTeststypeof mergeTestsPlaywright's mergeTests (1.39+) that keeps the step integration. Throws on older Playwright.
LoggerOptionstypeApiLoggerOptions & BrowserLoggerOptions, for defineConfig<LoggerOptions>().
ApiLoggerOptionstype{ apiLog: ApiLoggerConfig }.
BrowserLoggerOptionstype{ browserLog: BrowserLoggerConfig }.
BrowserLoggerFixturestype{ browserLogger: BrowserLogHandle }.
BrowserLogHandletypenote(), events(), render(), detach(). See Browser logging.
BrowserLoggerConfigtypeThe browserLog option type.

From playwright-logger-pro:

NameTypeDescription
wrapRequestContextfunctionWrap an APIRequestContext with API logging.
attachBrowserLoggerfunctionRecord a page or context you manage yourself.
buildCurlfunctionBuild the curl command for a RequestInfo.
resolveConfigfunctionValidate an ApiLoggerConfig and fill in defaults.
resolveBrowserConfigfunctionValidate a BrowserLoggerConfig and fill in defaults.
detectColorSupportfunctionThe colour auto-detection used by both loggers.
DEFAULT_CONFIGconstantResolved defaults of apiLog.
DEFAULT_BROWSER_CONFIGconstantResolved defaults of browserLog.
DEFAULT_REDACT_HEADERSconstantauthorization, proxy-authorization, cookie, set-cookie, x-api-key, x-auth-token.
DEFAULT_REDACT_QUERY_PARAMSconstantapi_key, apikey, token, access_token, refresh_token, key, password, secret, signature, sig.
DEFAULT_REDACT_BODY_KEYSconstantpassword, token, accessToken, refreshToken, secret, apiKey, cardToken, cardNumber, cvv, pin and the snake_case spellings of four of them.
renderCalls, renderCallLine, renderDetail, renderFooter, summarizefunctionsThe pure renderer of the compact output: records and options in, lines out.
buildCurlPartsfunctionThe terminal and the curl.sh form of one call's curl.
DEFAULT_SENSITIVE_KEYSconstantNames that usually hold secrets (password, token, api_key, authorization, cookie, otp, pin, cvv, ...), shared by both loggers.
DEFAULT_SENSITIVE_SELECTORSconstantPatterns matched against a target's description to decide whether a typed value is masked.
renderBrowserEventTextfunctionRender one browser event as text.
renderBrowserEventJsonlfunctionRender one browser event as a JSONL line.
formatRequestLinefunctionLow-level formatting helper.
formatResponseLinefunctionLow-level formatting helper.
formatErrorLinefunctionLow-level formatting helper.
formatHeadersfunctionLow-level formatting helper.
formatBodyfunctionLow-level formatting helper.
describeResponseBodyfunctionText to log for a response body (binary placeholder for non-text types).
describeMultipartfunctionDescribe a multipart payload for logs and curl.
escapeControlCharsfunctionEscape control characters in text.
redactHeadersfunctionMask header values by name.
redactUrlfunctionMask query parameter values in a URL.
redactQueryStringfunctionMask query parameter values in a query string.
redactBodyValuefunctionMask keys in a parsed body.
redactBodyStringfunctionMask keys in a body string (JSON, form).
truncateBodyfunctionTruncate a body at a character boundary.
stringifyBodyfunctionTurn a request body into a string.
ApiLoggerConfigtypeThe apiLog option type.
ResolvedConfigtypeApiLoggerConfig after resolveConfig().
BrowserLoggerConfigtypeThe browserLog option type.
BrowserRedactConfigtypeThe browserLog.redact option type.
ResolvedBrowserConfigtypeBrowserLoggerConfig after resolveBrowserConfig().
BrowserLogEventtypeThe event union, see the JSONL format.
BrowserLogHandletypeThe handle returned by attachBrowserLogger() and the browserLogger fixture.
CurlOptionstypeOptions of buildCurl.
RequestInfotypeThe request description buildCurl takes.
RedirectHoptypeOne request Playwright sent while following redirects.
Low-level helpers

The formatting and redaction helpers are exported for advanced use and are likely to be reviewed before 1.0. Signatures are in the API reference.

The BrowserLogEvent kinds are listed in Reporter & attachments.

Environment variables​

These decide the default for colors (both loggers) when you do not set it, in this order:

VariableEffect
NO_COLORNon-empty: colours off.
FORCE_COLOR, DEBUG_COLORS0 or false: colours off. Any other value (including empty for FORCE_COLOR): on. playwright test sets both for its workers, which is why colours normally work in test output although the workers' stdout is a pipe.
PLAYWRIGHT_FORCE_TTYAnything but 0/false: on.
TERM=dumbOff (checked before the TTY test).
TTYOn when stdout or stderr is a TTY; otherwise off.

colors: true or false in the options always wins, including over NO_COLOR.

VS Code play button

The VS Code Playwright extension's play button runs tests without a terminal, so auto-detection gives no colour. Colour it everywhere except on CI:

playwright.config.ts
use: { apiLog: { colors: !process.env.CI } },

Or on the reporter alone, leaving apiLog as it is:

playwright.config.ts
reporter: [['list'], ['playwright-logger-pro/reporter', { colors: !process.env.CI }]],

On CI that sets colors: false, so CI logs stay plain. See Compact output › Colours.

The curl command has its own, stricter rule and reads a few more variables:

VariableEffect
CI and the CI service variablesThe curl stays plain.
PLP_RUNNER_TTYSet by the library in the test runner process when the runner's own stdout is a terminal (<runner pid>:<colour depth>); workers inherit it and, when it names their parent, colour the curl by default. Do not set it yourself: it is ignored unless it holds the runner's pid. See Local runs in a terminal.
COLORTERM (truecolor, 24bit), TERM (contains 256color)The curl uses the 256-colour palette; otherwise the 16 basic colours.
VariableEffect
DEBUG=plp (any value containing plp)Prints a warning when the library could not hide its own frames from Playwright (step locations may then point into the library).

Examples​

playwright.config.ts
import { defineConfig } from '@playwright/test';
import type { LoggerOptions } from 'playwright-logger-pro/fixtures';

export default defineConfig<LoggerOptions>({
use: {
apiLog: {
curl: 'on-failure',
redactQueryParams: ['sig'],
redactBodyKeys: ['password'],
},
browserLog: {
print: process.env.CI ? 'on-failure' : true,
network: 'failed',
file: 'on-failure',
fileFormat: 'jsonl',
fileDir: 'logs/browser',
redact: {
values: [process.env.E2E_PASSWORD].filter((v): v is string => !!v),
selectors: ['#pin-pad'],
},
},
},
});