mirror of
https://github.com/Yubico/yubikey-val.git
synced 2024-12-04 06:24:17 +01:00
Refactor.
- init variables as class property, no need to init in construct. - set scopes on private properties, and public methods.
This commit is contained in:
parent
7503d42699
commit
f71b81fe6b
@ -29,12 +29,7 @@
|
|||||||
|
|
||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
function __construct($name='ykval')
|
private $log_levels = array(
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
$this->fields = array();
|
|
||||||
|
|
||||||
$this->LOG_LEVELS = array(
|
|
||||||
LOG_EMERG => 'LOG_EMERG',
|
LOG_EMERG => 'LOG_EMERG',
|
||||||
LOG_ALERT => 'LOG_ALERT',
|
LOG_ALERT => 'LOG_ALERT',
|
||||||
LOG_CRIT => 'LOG_CRIT',
|
LOG_CRIT => 'LOG_CRIT',
|
||||||
@ -42,18 +37,24 @@ class Log
|
|||||||
LOG_WARNING => 'LOG_WARNING',
|
LOG_WARNING => 'LOG_WARNING',
|
||||||
LOG_NOTICE => 'LOG_NOTICE',
|
LOG_NOTICE => 'LOG_NOTICE',
|
||||||
LOG_INFO => 'LOG_INFO',
|
LOG_INFO => 'LOG_INFO',
|
||||||
LOG_DEBUG => 'LOG_DEBUG'
|
LOG_DEBUG => 'LOG_DEBUG',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private $fields = array();
|
||||||
|
|
||||||
|
public function __construct ($name = 'ykval')
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
openlog('ykval', LOG_PID, LOG_LOCAL0);
|
openlog('ykval', LOG_PID, LOG_LOCAL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addField($name, $value)
|
public function addField($name, $value)
|
||||||
{
|
{
|
||||||
$this->fields[$name] = $value;
|
$this->fields[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function log($priority, $message, $arr=null)
|
public function log ($priority, $message, $arr=null)
|
||||||
{
|
{
|
||||||
if (is_array($arr)) {
|
if (is_array($arr)) {
|
||||||
foreach($arr as $key => $value){
|
foreach($arr as $key => $value){
|
||||||
@ -70,7 +71,7 @@ class Log
|
|||||||
}
|
}
|
||||||
|
|
||||||
syslog($priority,
|
syslog($priority,
|
||||||
$this->LOG_LEVELS[$priority] . ':' .
|
$this->log_levels[$priority] . ':' .
|
||||||
$this->name . ':' .
|
$this->name . ':' .
|
||||||
$msg_fields .
|
$msg_fields .
|
||||||
$message);
|
$message);
|
||||||
|
Loading…
Reference in New Issue
Block a user