Skip to content

Commit

Permalink
Fix error logging to syslog
Browse files Browse the repository at this point in the history
Fix notice in examples
  • Loading branch information
sveneld authored and jparise committed Feb 20, 2024
1 parent 8d27054 commit 6c7838a
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Log/syslog.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function __construct(
}

$this->id = md5(microtime().random_int(0, mt_getrandmax()));
$this->name = $name;
$this->name = (int)$name;
$this->ident = $ident;
$this->mask = Log::MAX($level);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require_once 'Log.php';

$console = &Log::singleton('console', '', 'TEST');
$file = &Log::singleton('file', 'out.log', 'TEST');
$console = Log::singleton('console', '', 'TEST');
$file = Log::singleton('file', 'out.log', 'TEST');

$composite = &Log::singleton('composite');
$composite = Log::singleton('composite');
$composite->addChild($console);
$composite->addChild($file);

Expand Down
2 changes: 1 addition & 1 deletion examples/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once 'Log.php';

$logger = &Log::singleton('console', '', 'ident');
$logger = Log::singleton('console', '', 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'error_prepend' => '<font color="#ff0000"><tt>',
'error_append' => '</tt></font>'
];
$logger = &Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);
$logger = Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/error_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once 'Log.php';

$logger = &Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');
$logger = Log::singleton('error_log', PEAR_LOG_TYPE_SYSTEM, 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once 'Log.php';

$conf = ['mode' => 0600, 'timeFormat' => '%X %x'];
$logger = &Log::singleton('file', 'out.log', 'ident', $conf);
$logger = Log::singleton('file', 'out.log', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/firebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once 'Log.php';

$logger = &Log::singleton(
$logger = Log::singleton(
'firebug',
'',
'PHP',
Expand Down
2 changes: 1 addition & 1 deletion examples/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once 'Log.php';

$conf = ['subject' => 'Important Log Events'];
$logger = &Log::singleton('mail', '[email protected]', 'ident', $conf);
$logger = Log::singleton('mail', '[email protected]', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/null.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once 'Log.php';

$logger = &Log::singleton('null');
$logger = Log::singleton('null');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/observer_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct($priority, $conf)
$this->pattern = $conf['pattern'];
}

public function notify($event)
public function notify($event): void
{
if (preg_match($this->pattern, $event['message']) != 0) {
mail($this->to, $this->subject, $event['message']);
Expand Down
2 changes: 1 addition & 1 deletion examples/pear_error_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function errorHandler($error)
$logger->log($message, $error->code);
}

$logger = &Log::singleton('console', '', 'ident');
$logger = Log::singleton('console', '', 'ident');

PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorHandler');
PEAR::raiseError('This is an information log message.', PEAR_LOG_INFO);
2 changes: 1 addition & 1 deletion examples/php_error_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function errorHandler($code, $message, $file, $line)
$priority);
}

$logger = &Log::singleton('console', '', 'ident');
$logger = Log::singleton('console', '', 'ident');

set_error_handler('errorHandler');
trigger_error('This is an information log message.', E_USER_NOTICE);
2 changes: 1 addition & 1 deletion examples/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once 'Log.php';

$conf = ['dsn' => 'pgsql://jon@localhost+unix/logs'];
$logger = &Log::singleton('sql', 'log_table', 'ident', $conf);
$logger = Log::singleton('sql', 'log_table', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
4 changes: 2 additions & 2 deletions examples/sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

/* Creating a new database connection. */
$conf = ['filename' => 'log.db', 'mode' => 0666, 'persistent' => true];
$logger =& Log::factory('sqlite', 'log_table', 'ident', $conf);
$logger = Log::factory('sqlite', 'log_table', 'ident', $conf);
$logger->log('logging an event', PEAR_LOG_WARNING);

/* Using an existing database connection. */
$db = sqlite_open('log.db', 0666, $error);
$logger =& Log::factory('sqlite', 'log_table', 'ident', $db);
$logger = Log::factory('sqlite', 'log_table', 'ident', $db);
$logger->log('logging an event', PEAR_LOG_WARNING);
sqlite_close($db);
2 changes: 1 addition & 1 deletion examples/syslog.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once 'Log.php';

$logger = &Log::singleton('syslog', LOG_LOCAL0, 'ident');
$logger = Log::singleton('syslog', LOG_LOCAL0, 'ident');
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}
2 changes: 1 addition & 1 deletion examples/win.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once 'Log.php';

$conf = ['title' => 'Sample Log Output'];
$logger = &Log::singleton('win', 'LogWindow', 'ident', $conf);
$logger = Log::singleton('win', 'LogWindow', 'ident', $conf);
for ($i = 0; $i < 10; $i++) {
$logger->log("Log entry $i");
}

0 comments on commit 6c7838a

Please sign in to comment.