1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-12-03 21:24:18 +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,31 +29,32 @@
class Log class Log
{ {
function __construct($name='ykval') private $log_levels = array(
LOG_EMERG => 'LOG_EMERG',
LOG_ALERT => 'LOG_ALERT',
LOG_CRIT => 'LOG_CRIT',
LOG_ERR => 'LOG_ERR',
LOG_WARNING => 'LOG_WARNING',
LOG_NOTICE => 'LOG_NOTICE',
LOG_INFO => 'LOG_INFO',
LOG_DEBUG => 'LOG_DEBUG',
);
private $fields = array();
public function __construct ($name = 'ykval')
{ {
$this->name = $name; $this->name = $name;
$this->fields = array();
$this->LOG_LEVELS = array(
LOG_EMERG => 'LOG_EMERG',
LOG_ALERT => 'LOG_ALERT',
LOG_CRIT => 'LOG_CRIT',
LOG_ERR => 'LOG_ERR',
LOG_WARNING => 'LOG_WARNING',
LOG_NOTICE => 'LOG_NOTICE',
LOG_INFO => 'LOG_INFO',
LOG_DEBUG => 'LOG_DEBUG'
);
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);