From 3010ae8c85fe8cb656c9e96a95d0efee0fb2126a Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Sat, 26 Jan 2013 12:59:02 -0500 Subject: Log stderr when we transcode Now you shouldn't need to manually run the command to see what went wrong. --- docs/CHANGELOG | 1 + lib/class/stream.class.php | 12 +++++++++++- lib/log.lib.php | 5 ++++- play/index.php | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index fc228610..7795dd27 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.6-FUTURE + - stderr from the transcode command is now logged for debugging - Made database updates more robust and verified that a fresh 3.3.3.5 import will run through the updates without errors - Added support for external authenticators like pwauth (based on a patch by diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 35d4eb64..c21f5823 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -135,8 +135,18 @@ class Stream { debug_event('downsample', "Downsample command: $command", 3); + $process = proc_open( + $command, + array( + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w') + ), + $pipes + ); return array( - 'handle' => popen($command, 'rb'), + 'process' => $process, + 'handle' => $pipes[1], + 'stderr' => $pipes[2], 'format' => $transcode_settings['format'] ); diff --git a/lib/log.lib.php b/lib/log.lib.php index 19aad964..6f9df914 100644 --- a/lib/log.lib.php +++ b/lib/log.lib.php @@ -134,7 +134,10 @@ function debug_event($type, $message, $level, $file = '', $username = '') { $username = $GLOBALS['user']->username; } - log_event($username, $type, $message, $file); + // If the message is multiple lines, make multiple log lines + foreach (explode("\n", $message) as $line) { + log_event($username, $type, $line, $file); + } } // debug_event diff --git a/play/index.php b/play/index.php index a6638e0c..238e963f 100644 --- a/play/index.php +++ b/play/index.php @@ -462,7 +462,11 @@ else { if ($demo_id) { $democratic->delete_from_oid($oid,'song'); } if ($transcode) { - pclose($fp); + $stderr = fread($transcoder['stderr'], 8192); + fclose($transcoder['stderr']); + fclose($fp); + proc_close($transcoder['process']); + debug_event('transcode_cmd', $stderr, 5); } else { fclose($fp); -- cgit