Skip to content

Commit 4438e24

Browse files
committed
Read non-structured Prince messages
1 parent e64900c commit 4438e24

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Prince.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2342,14 +2342,31 @@ private function readMessages($pipe, &$msgs, &$dats)
23422342

23432343
$dats[] = $dat;
23442344
} else {
2345-
// ignore other messages
2345+
self::readNonStructuredMessage($line, $msgs);
23462346
}
23472347
}
23482348
}
23492349

23502350
return '';
23512351
}
23522352

2353+
private function readNonStructuredMessage($line, &$msgs)
2354+
{
2355+
$princeWrn = 'prince: warning: ';
2356+
$princeErr = 'prince: error: ';
2357+
2358+
if (substr($line, 0, strlen($princeWrn)) === $princeWrn) {
2359+
$msgText = substr($line, strlen($princeWrn));
2360+
$msgs[] = array('wrn', '', $msgText);
2361+
} else if (substr($line, 0, strlen($princeErr)) === $princeErr) {
2362+
$msgText = substr($line, strlen($princeErr));
2363+
$msgs[] = array('err', '', $msgText);
2364+
} else {
2365+
// Just treat everything else as debug messages.
2366+
$msgs[] = array('dbg', '', $line);
2367+
}
2368+
}
2369+
23532370
private static function cmdArg($key, $value = null)
23542371
{
23552372
$cmd = $key;

0 commit comments

Comments
 (0)