diff --git a/lib/commands/log.js b/lib/commands/log.js index 1ebe96557..439e0adf6 100644 --- a/lib/commands/log.js +++ b/lib/commands/log.js @@ -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'; /** @@ -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() ); }