Skip to content

Commit

Permalink
Merge pull request PrestaShop#1123 from M0rgan01/fix-log-regex
Browse files Browse the repository at this point in the history
[NEW-UI] Fix log regex
  • Loading branch information
Quetzacoalt91 authored Jan 16, 2025
2 parents d187080 + 7bd523b commit 7a342a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _dev/src/ts/utils/logsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const severityPattern = [
*/
export function parseLogWithSeverity(log: string): LogEntry {
const logTrimed = log.trim();
const severityRegex = new RegExp(`^(${severityPattern})\\s*-\\s*(.*)$`);
const severityRegex = new RegExp(`^(${severityPattern})\\s*-\\s*(.*)$`, 's');
const match = severityRegex.exec(logTrimed);

if (match) {
Expand Down
12 changes: 12 additions & 0 deletions _dev/tests/utils/logsUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ describe('parseLogWithSeverity', () => {
});
});

it('should parse a log with SUCCESS severity on multi-line', () => {
const log = `DEBUG - Migration file: 8.1.7-catchup, Query: /* 8.0.0 */
DROP TABLE IF EXISTS \`ps_attribute_impact\``;
const result = parseLogWithSeverity(log);

expect(result).toEqual<LogEntry>({
severity: Severity.SUCCESS,
message:
'Migration file: 8.1.7-catchup, Query: /* 8.0.0 */\nDROP TABLE IF EXISTS `ps_attribute_impact`'
});
});

it('should parse a log with WARNING severity', () => {
const log = 'WARNING - Disk space is low';
const result = parseLogWithSeverity(log);
Expand Down

0 comments on commit 7a342a1

Please sign in to comment.