Skip to content

Commit

Permalink
fix: Strip colors from server logs (#2466)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Sep 13, 2024
1 parent 10344ac commit 661f9d3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/commands/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { NATIVE_WIN, BIDI_EVENT_NAME } from '../utils';
*/
const WEBSOCKET_ENDPOINT = (sessionId) =>
`${DEFAULT_WS_PATHNAME_PREFIX}/session/${sessionId}/appium/device/syslog`;

const COLOR_CODE_PATTERN = /\u001b\[(\d+(;\d+)*)?m/g; // eslint-disable-line no-control-regex
const GET_SERVER_LOGS_FEATURE = 'get_server_logs';

/**
Expand All @@ -26,8 +26,9 @@ const GET_SERVER_LOGS_FEATURE = 'get_server_logs';
* @returns {import('./types').LogEntry}
*/
function nativeLogEntryToSeleniumEntry (x) {
const msg = _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`;
return toLogEntry(
_.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`,
_.replace(msg, COLOR_CODE_PATTERN, ''),
/** @type {any} */ (x).timestamp ?? Date.now()
);
}
Expand Down

0 comments on commit 661f9d3

Please sign in to comment.