swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.25k stars 3.16k forks source link

Suggestion: Better core logging #5278

Open ValiDrv opened 1 month ago

ValiDrv commented 1 month ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.

We have Swoole applications in docker running on multiple servers, sending logs to a central server via syslog. We are having issues with grouping multiple core Swoole errors error lines in one line.

For example: if the function deadlock_check() would have a few spaces, it would make grouping and parsing those logs allot easier. Current:

echo "\n===================================================================",
    "\n [FATAL ERROR]: all coroutines (count: {$count}) are asleep - deadlock!",
    "\n===================================================================\n";
...
echo "\n [Coroutine-{$cid}]";
echo "\n--------------------------------------------------------------------\n";
echo Coroutine::printBackTrace($cid, DEBUG_BACKTRACE_IGNORE_ARGS, $depth);
echo "\n";

Suggestion:

echo "\n===================================================================",
    "\n [FATAL ERROR]: all coroutines (count: {$count}) are asleep - deadlock!",
    "\n "; # << add a space
//    "\n ===================================================================\n"; 
...
echo "\n [Coroutine-{$cid}]";
echo "\n --------------------------------------------------------------------\n"; # << prefix with a space
echo Coroutine::printBackTrace($cid, DEBUG_BACKTRACE_IGNORE_ARGS, $depth); # << prefix with a spaces
echo "\n "; # << prefix with a space

And this should probably be the case for all logs that act as a unit, including Swoole crash logs and so on.