summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-06-04 22:40:35 -0400
committerEvan Prodromou <evan@prodromou.name>2008-06-04 22:40:35 -0400
commitd241352dcc2c641bcf97efee596c0cfba4d34dc5 (patch)
treea78615ee5eab0b91f0a5d37b90da43e0bbf0b0b9 /lib
parent593f1e5e2c23c771b1cc9ba8c352639f1ec96a48 (diff)
automatically prepend filename to debug output
darcs-hash:20080605024035-84dde-bc3abc4329f3181cffd26e83d37968ee6a02a26e.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/common.php1
-rw-r--r--lib/util.php13
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/common.php b/lib/common.php
index 19b0e4b64..b2c0a7b46 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -35,6 +35,7 @@ require_once('DB/DataObject/Cast.php'); # for dates
$config =
array('site' =>
array('name' => 'Just another Laconica microblog',
+ 'appname' => 'laconica', # for syslog
'server' => 'localhost',
'path' => '/',
'fancy' => false),
diff --git a/lib/util.php b/lib/util.php
index a222f85f6..7171211da 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -575,19 +575,22 @@ function _t($str) {
function common_ensure_syslog() {
static $initialized = false;
if (!$initialized) {
+ global $config;
define_syslog_variables();
- openlog("laconica", 0, LOG_USER);
+ openlog($config['site']['appname'], 0, LOG_USER);
$initialized = true;
}
}
-function common_log($priority, $msg) {
+function common_log($priority, $msg, $filename=NULL) {
common_ensure_syslog();
- syslog($priority, $msg);
+ if ($filename) {
+ syslog($priority, basename($filename).' - '.$msg);
+ }
}
-function common_debug($msg) {
- common_log(LOG_DEBUG, $msg);
+function common_debug($msg, $filename=NULL) {
+ common_log(LOG_DEBUG, $msg, $filename);
}
function common_valid_http_url($url) {