Skip to content

Commit

Permalink
Merge pull request #4 from xp-framework/category-generic-log-method
Browse files Browse the repository at this point in the history
Generic LogCategory::log($level, $args)
  • Loading branch information
thekid committed Jan 2, 2014
2 parents b40d64e + a324c7a commit 3d08e4d
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 216 deletions.
20 changes: 10 additions & 10 deletions src/main/php/util/log/LogCategory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function getFlags() {
* @param int level
* @param var[] args
*/
protected function callAppenders($level, $args) {
public function log($level, $args) {
if (!($this->flags & $level)) return;
$event= new LoggingEvent($this, time(), getmypid(), $level, $args);
foreach ($this->_appenders as $appflag => $appenders) {
Expand Down Expand Up @@ -231,7 +231,7 @@ public function getAppenders($flag= LogLevel::ALL) {
*/
public function info() {
$args= func_get_args();
$this->callAppenders(LogLevel::INFO, $args);
$this->log(LogLevel::INFO, $args);
}

/**
Expand All @@ -247,7 +247,7 @@ public function info() {
*/
public function infof() {
$args= func_get_args();
$this->callAppenders(LogLevel::INFO, array(vsprintf($args[0], array_slice($args, 1))));
$this->log(LogLevel::INFO, array(vsprintf($args[0], array_slice($args, 1))));
}

/**
Expand All @@ -257,7 +257,7 @@ public function infof() {
*/
public function warn() {
$args= func_get_args();
$this->callAppenders(LogLevel::WARN, $args);
$this->log(LogLevel::WARN, $args);
}

/**
Expand All @@ -268,7 +268,7 @@ public function warn() {
*/
public function warnf() {
$args= func_get_args();
$this->callAppenders(LogLevel::WARN, array(vsprintf($args[0], array_slice($args, 1))));
$this->log(LogLevel::WARN, array(vsprintf($args[0], array_slice($args, 1))));
}

/**
Expand All @@ -278,7 +278,7 @@ public function warnf() {
*/
public function error() {
$args= func_get_args();
$this->callAppenders(LogLevel::ERROR, $args);
$this->log(LogLevel::ERROR, $args);
}

/**
Expand All @@ -289,7 +289,7 @@ public function error() {
*/
public function errorf() {
$args= func_get_args();
$this->callAppenders(LogLevel::ERROR, array(vsprintf($args[0], array_slice($args, 1))));
$this->log(LogLevel::ERROR, array(vsprintf($args[0], array_slice($args, 1))));
}

/**
Expand All @@ -299,7 +299,7 @@ public function errorf() {
*/
public function debug() {
$args= func_get_args();
$this->callAppenders(LogLevel::DEBUG, $args);
$this->log(LogLevel::DEBUG, $args);
}

/**
Expand All @@ -310,15 +310,15 @@ public function debug() {
*/
public function debugf() {
$args= func_get_args();
$this->callAppenders(LogLevel::DEBUG, array(vsprintf($args[0], array_slice($args, 1))));
$this->log(LogLevel::DEBUG, array(vsprintf($args[0], array_slice($args, 1))));
}

/**
* Appends a separator (a "line" consisting of 72 dashes)
*
*/
public function mark() {
$this->callAppenders(LogLevel::INFO, array(str_repeat('-', 72)));
$this->log(LogLevel::INFO, array(str_repeat('-', 72)));
}

/**
Expand Down
Loading

0 comments on commit 3d08e4d

Please sign in to comment.