Merge branch '2.5.x' into saas

Conflicts:
	airtime_mvc/application/controllers/ScheduleController.php
	airtime_mvc/public/index.php
This commit is contained in:
Albert Santoni 2015-01-27 18:26:39 -05:00
commit 1ddc27bb77
3 changed files with 41 additions and 50 deletions

View File

@ -139,7 +139,6 @@ class ScheduleController extends Zend_Controller_Action
$editable = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); $editable = $user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$calendar_interval = Application_Model_Preference::GetCalendarTimeScale(); $calendar_interval = Application_Model_Preference::GetCalendarTimeScale();
// Logging::info($calendar_interval);
if ($calendar_interval == "agendaDay") { if ($calendar_interval == "agendaDay") {
list($start, $end) = Application_Model_Show::getStartEndCurrentDayView(); list($start, $end) = Application_Model_Show::getStartEndCurrentDayView();
} else if ($calendar_interval == "agendaWeek") { } else if ($calendar_interval == "agendaWeek") {

View File

@ -38,52 +38,50 @@ class Logging {
return $p_msg; return $p_msg;
} }
} }
/** @param debugMode Prints the function name, file, and line number. This is slow as it uses debug_backtrace()
* so don't use it unless you need it.
*/
private static function getLinePrefix($debugMode=false)
{
$linePrefix = "";
if (array_key_exists('SERVER_NAME', $_SERVER)) {
$linePrefix .= $_SERVER['SERVER_NAME'] . " ";
}
if ($debugMode) {
//debug_backtrace is SLOW so we don't want this invoke unless there was a real error! (hence $debugMode)
$bt = debug_backtrace();
$caller = $bt[1];
$file = basename($caller['file']);
$line = $caller['line'];
$function = "Unknown function";
if (array_key_exists(2, $bt)) {
$function = $bt[2]['function'];
}
$linePrefix .= "[$file:$line - $function()] - ";
}
return $linePrefix;
}
public static function info($p_msg) public static function info($p_msg)
{ {
$bt = debug_backtrace();
$caller = array_shift($bt);
$file = basename($caller['file']);
$line = $caller['line'];
$caller = array_shift($bt);
$function = $caller['function'];
$logger = self::getLogger(); $logger = self::getLogger();
$logger->info($_SERVER['SERVER_NAME'] . " [$file : $function() : line $line] - ".self::toString($p_msg)); $logger->info(self::getLinePrefix() . self::toString($p_msg));
} }
public static function warn($p_msg) public static function warn($p_msg)
{ {
$bt = debug_backtrace();
$caller = array_shift($bt);
$file = basename($caller['file']);
$line = $caller['line'];
$caller = array_shift($bt);
$function = $caller['function'];
$logger = self::getLogger(); $logger = self::getLogger();
$logger->warn($_SERVER['SERVER_NAME'] . " [$file : $function() : line $line] - " $logger->warn(self::getLinePrefix() . self::toString($p_msg));
. self::toString($p_msg));
} }
public static function error($p_msg) public static function error($p_msg)
{ {
$bt = debug_backtrace();
$caller = array_shift($bt);
$file = basename($caller['file']);
$line = $caller['line'];
$caller = array_shift($bt);
$function = $caller['function'];
$logger = self::getLogger(); $logger = self::getLogger();
$logger->err($_SERVER['SERVER_NAME'] . " [$file : $function() : line $line] - " $logger->err(self::getLinePrefix(true) . self::toString($p_msg));
. self::toString($p_msg));
} }
public static function debug($p_msg) public static function debug($p_msg)
@ -92,17 +90,8 @@ class Logging {
return; return;
} }
$bt = debug_backtrace();
$caller = array_shift($bt);
$file = basename($caller['file']);
$line = $caller['line'];
$caller = array_shift($bt);
$function = $caller['function'];
$logger = self::getLogger(); $logger = self::getLogger();
$logger->debug($_SERVER['SERVER_NAME'] . " [$file : $function() : line $line] - ".self::toString($p_msg)); $logger->debug(self::getLinePrefix(true) . self::toString($p_msg));
} }
// kind of like debug but for printing arrays more compactly (skipping // kind of like debug but for printing arrays more compactly (skipping
// empty elements // empty elements

View File

@ -90,15 +90,18 @@ try {
$application->bootstrap()->run(); $application->bootstrap()->run();
} }
} catch (Exception $e) { } catch (Exception $e) {
echo $e->getMessage();
echo "<pre>"; header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
echo $e->getTraceAsString();
echo "</pre>"; Logging::error($e->getMessage());
Logging::info($e->getMessage());
if (VERBOSE_STACK_TRACE) { if (VERBOSE_STACK_TRACE) {
Logging::info($e->getTraceAsString()); echo $e->getMessage();
echo "<pre>";
echo $e->getTraceAsString();
echo "</pre>";
Logging::error($e->getTraceAsString());
} else { } else {
Logging::info($e->getTrace()); Logging::error($e->getTrace());
} }
throw $e; throw $e;
} }