mirror of
https://github.com/zhamao-robot/zhamao-logger.git
synced 2026-03-17 12:34:52 +08:00
change method sign to static
This commit is contained in:
parent
9da98fde5a
commit
0ee6e43f06
@ -139,6 +139,27 @@ class ConsoleLogger extends AbstractLogger
|
||||
return self::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入字段到指定字段之前,或之后
|
||||
* @param string $field 字段名
|
||||
* @param string $alter 要插入的字段
|
||||
* @param string $position 插入位置,before 或 after
|
||||
*/
|
||||
public static function alterFormat(string $field, string $alter, string $position = 'before'): void
|
||||
{
|
||||
$format = self::$format;
|
||||
$pos = strpos($format, $field);
|
||||
if ($pos === false) {
|
||||
return;
|
||||
}
|
||||
if ($position === 'before') {
|
||||
$format = substr_replace($format, $alter, $pos, 0);
|
||||
} else {
|
||||
$format = substr_replace($format, $alter, $pos + strlen($field), 0);
|
||||
}
|
||||
self::$format = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加静态上下文
|
||||
*/
|
||||
@ -203,27 +224,6 @@ class ConsoleLogger extends AbstractLogger
|
||||
return ConsoleColor::apply($styles, $string)->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入字段到指定字段之前,或之后
|
||||
* @param string $field 字段名
|
||||
* @param string $alter 要插入的字段
|
||||
* @param string $position 插入位置,before 或 after
|
||||
*/
|
||||
public function alterFormat(string $field, string $alter, string $position = 'before'): void
|
||||
{
|
||||
$format = self::$format;
|
||||
$pos = strpos($format, $field);
|
||||
if ($pos === false) {
|
||||
return;
|
||||
}
|
||||
if ($position === 'before') {
|
||||
$format = substr_replace($format, $alter, $pos, 0);
|
||||
} else {
|
||||
$format = substr_replace($format, $alter, $pos + strlen($field), 0);
|
||||
}
|
||||
self::$format = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user