1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-12-01 15:24:16 +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:
Jean Paul Galea 2015-09-10 20:17:22 +02:00
parent 7503d42699
commit f71b81fe6b

View File

@ -29,12 +29,7 @@
class Log
{
function __construct($name='ykval')
{
$this->name = $name;
$this->fields = array();
$this->LOG_LEVELS = array(
private $log_levels = array(
LOG_EMERG => 'LOG_EMERG',
LOG_ALERT => 'LOG_ALERT',
LOG_CRIT => 'LOG_CRIT',
@ -42,18 +37,24 @@ class Log
LOG_WARNING => 'LOG_WARNING',
LOG_NOTICE => 'LOG_NOTICE',
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);
}
function addField($name, $value)
public function addField($name, $value)
{
$this->fields[$name] = $value;
}
function log($priority, $message, $arr=null)
public function log ($priority, $message, $arr=null)
{
if (is_array($arr)) {
foreach($arr as $key => $value){
@ -70,7 +71,7 @@ class Log
}
syslog($priority,
$this->LOG_LEVELS[$priority] . ':' .
$this->log_levels[$priority] . ':' .
$this->name . ':' .
$msg_fields .
$message);