Add a general log method to Logger class
the params order is the actual correct one: log level, message, context, group_id, prefix not that group_id and prefix are only used if log level is debug Switched debug params order for context and prefix so prefix is last
This commit is contained in:
@@ -910,6 +910,42 @@ class Logging
|
||||
// MAIN CALLS
|
||||
// *********************************************************************
|
||||
|
||||
/**
|
||||
* Commong log interface
|
||||
*
|
||||
* extended with group_id, prefix that are ONLY used for debug level
|
||||
*
|
||||
* @param Level $level
|
||||
* @param string|\Stringable $message
|
||||
* @param mixed[] $context
|
||||
* @param string $group_id
|
||||
* @param string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function log(
|
||||
Level $level,
|
||||
string|\Stringable $message,
|
||||
array $context = [],
|
||||
string $group_id = '',
|
||||
string $prefix = '',
|
||||
): bool {
|
||||
// if we are not debug, ignore group_id and prefix
|
||||
if ($level != Level::Debug) {
|
||||
$group_id = '';
|
||||
$prefix = '';
|
||||
}
|
||||
return $this->writeErrorMsg(
|
||||
$level,
|
||||
$this->prepareLog(
|
||||
$level,
|
||||
$prefix . $message,
|
||||
$context,
|
||||
$group_id
|
||||
),
|
||||
$group_id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG: 100
|
||||
*
|
||||
@@ -927,8 +963,8 @@ class Logging
|
||||
public function debug(
|
||||
string $group_id,
|
||||
string|\Stringable $message,
|
||||
string $prefix = '',
|
||||
array $context = []
|
||||
array $context = [],
|
||||
string $prefix = ''
|
||||
): bool {
|
||||
return $this->writeErrorMsg(
|
||||
Level::Debug,
|
||||
|
||||
Reference in New Issue
Block a user