Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orion 15.10.0 plat 10266 #8860

Merged
merged 6 commits into from Nov 5, 2019

revert changes

  • Loading branch information
MosheMaorKaltura committed Nov 4, 2019
commit c6efa6911006268c0f5006d2cabd086a4ba44478
@@ -3,7 +3,6 @@
* @package infra
* @subpackage monitor
*/

class KalturaMonitorClient
{
const MAX_PACKET_SIZE = 1400;
@@ -61,20 +60,19 @@ class KalturaMonitorClient

public static function prettyPrintCounters()
{
$str = '';
$str='';
foreach (self::$sessionCounters as $key => $value)
{
$str .= $key . ':' . $value . ' ';
}
return $str;
}

protected static function init()
{
if(!kConf::hasParam('monitor_uri'))
return null;


$uri = kConf::get('monitor_uri');
$pathInfo = parse_url($uri);
if(isset($pathInfo['host']) && $pathInfo['port'])
@@ -208,8 +206,8 @@ public static function monitorApiEnd($errorCode)

public static function monitorDatabaseAccess($sql, $sqlTook, $hostName = null)
{
/*if (!self::$stream)
return;*/
if (!self::$stream)
return;

// strip the comment
if (substr($sql, 0, 2) == '/*')
@@ -18,8 +18,8 @@ protected function partnerRequired($actionName)
}
return parent::partnerRequired($actionName);
}

/**
/**
* @action ping
* @return bool Always true if service is working
* @ksIgnored
@@ -78,20 +78,4 @@ function getVersionAction()
$version = file_get_contents(realpath(dirname(__FILE__)) . '/../../VERSION.txt');
return trim($version);
}

/**
* @action getCounters
* @param bool $shouldClear
* @return string that contains json of counters
* @ksignored
*/
function getCountersAction($shouldClear = false)
{
KalturaLog::crit('aa');
KalturaResponseCacher::disableCache();
$serverCounters = array();
$serverCounters['loggerCounters'] = KalturaLog::getStoredCounters($shouldClear);
$serverCounters['sessionCounters'] = KalturaMonitorClient::getStoredCounters($shouldClear);
return (json_encode($serverCounters));
}
}
@@ -10,71 +10,17 @@ class KalturaLog
private static $_instance = null;
private static $_enableTests = false;

const EMERG = Zend_Log::EMERG;
const ALERT = Zend_Log::ALERT;
const CRIT = Zend_Log::CRIT;
const ERR = Zend_Log::ERR;
const WARN = Zend_Log::WARN;
const NOTICE = Zend_Log::NOTICE;
const INFO = Zend_Log::INFO;
const DEBUG = Zend_Log::DEBUG;

const LOG_TYPE_ANALYTICS = 'LOG_TYPE_ANALYTICS';
const STANDARD_ERROR = 'STANDARD_ERROR';

static protected $sessionCounters = array (
self::EMERG => 0,
self::ALERT => 0,
self::CRIT => 0,
self::ERR => 0,
self::WARN => 0,
self::NOTICE => 0,
self::INFO => 0,
self::DEBUG => 0 );

const COUNTERS_PREFIX = '_LOG_COUNTERS_';
public static function storeCounters()
{
foreach (self::$sessionCounters as $key => $value)
{
if($value)
{
$success = true;
apc_inc(self::COUNTERS_PREFIX . $key, $value, $success);
if(!$success)
{
apc_store(self::COUNTERS_PREFIX . $key, $value);
}
}
}
}

public static function getStoredCounters($shouldClear)
{
$counters = array();
foreach (self::$sessionCounters as $key => $dummy)
{
$value = apc_fetch(self::COUNTERS_PREFIX . $key);
$counters[" $key "] = $value ? $value : 0;
if($shouldClear)
{
apc_delete(self::COUNTERS_PREFIX . $key);
}
}
return $counters;
}

protected static function increaseLogCounters($priority)
{
if(isset(self::$sessionCounters[$priority]))
{
self::$sessionCounters[$priority]++;
}
else
{
self::$sessionCounters[$priority]=1;
}
}
const EMERG = Zend_Log::EMERG;
const ALERT = Zend_Log::ALERT;
const CRIT = Zend_Log::CRIT;
const ERR = Zend_Log::ERR;
const WARN = Zend_Log::WARN;
const NOTICE = Zend_Log::NOTICE;
const INFO = Zend_Log::INFO;
const DEBUG = Zend_Log::DEBUG;

const LOG_TYPE_ANALYTICS = 'LOG_TYPE_ANALYTICS';
const STANDARD_ERROR = 'STANDARD_ERROR';

public static function isInitialized()
{
@@ -84,8 +30,8 @@ public static function isInitialized()
public static function getInstance ()
{
if (!self::$_instance)
self::$_instance = new KalturaLog();

self::$_instance = new KalturaLog();
return self::$_instance;
}

@@ -114,63 +60,58 @@ public static function setLogger($logger)
static function log($message, $priority = self::NOTICE)
{
self::initLog();
self::callLogger($message, $priority);
self::$_logger->log($message, $priority);
}

static function alert($message)
{
self::initLog();
if(!$message instanceof Exception)
$message = new Exception($message);
self::callLogger($message, self::ALERT);

self::$_logger->log($message, self::ALERT);
}

static function crit($message)
{
self::initLog();
if(!$message instanceof Exception)
$message = new Exception($message);

self::callLogger($message, self::CRIT);
self::$_logger->log($message, self::CRIT);
}

static function err($message)
{
self::initLog();
if(!$message instanceof Exception)
$message = new Exception($message);

self::callLogger($message, self::ERR);
}
self::$_logger->log($message, self::ERR);
}

static function warning($message)
{
self::initLog();
self::callLogger($message, self::WARN);
self::$_logger->log($message, self::WARN);
}

static function notice($message)
{
self::initLog();
self::callLogger($message, self::NOTICE);
}
self::$_logger->log($message, self::NOTICE);
}

static function info($message)
{
self::initLog();
self::callLogger($message, self::INFO);
self::$_logger->log($message, self::INFO);
}

static function debug($message)
{
self::initLog();
self::callLogger($message, self::DEBUG);
}

static protected function callLogger($message,$priority)
{
self::$_logger->log($message, $priority);
self::increaseLogCounters($priority);
self::$_logger->log($message, self::DEBUG);
}

static function analytics(array $data)
@@ -233,9 +174,9 @@ public function log($message, $priority = KalturaLog::NOTICE)
*/
class KalturaNullLogger
{
public function log($message, $priority = KalturaLog::NOTICE)
{
}
public function log($message, $priority = KalturaLog::NOTICE)
{
}
}

/**
@@ -310,7 +251,7 @@ public function __toString()
self::$_lastMicroTime = $GLOBALS["start"];
else
self::$_lastMicroTime = $curTime;
}
}
$result = sprintf("%.6f", $curTime - self::$_lastMicroTime);

self::$_lastMicroTime = $curTime;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.