parameter to strip codes from log messages

This commit is contained in:
Steffen Schröder 2014-08-05 00:55:32 +02:00
parent b8fb6f9364
commit 8738deeb46

View File

@ -3,6 +3,7 @@
namespace ManiaControl; namespace ManiaControl;
use ManiaControl\Files\FileUtil; use ManiaControl\Files\FileUtil;
use ManiaControl\Utils\Formatter;
/** /**
* ManiaControl Logger Class * ManiaControl Logger Class
@ -73,10 +74,11 @@ abstract class Logger {
* @param string $message * @param string $message
* @param bool $eol * @param bool $eol
* @param bool $output * @param bool $output
* @param bool $stripCodes
*/ */
public static function logError($message, $eol = true, $output = true) { public static function logError($message, $eol = true, $output = true, $stripCodes = false) {
$message = '[ERROR] ' . $message; $message = '[ERROR] ' . $message;
self::log($message, $eol, $output); self::log($message, $eol, $output, $stripCodes);
} }
/** /**
@ -85,8 +87,12 @@ abstract class Logger {
* @param string $message * @param string $message
* @param bool $eol * @param bool $eol
* @param bool $output * @param bool $output
* @param bool $stripCodes
*/ */
public static function log($message, $eol = true, $output = true) { public static function log($message, $eol = true, $output = true, $stripCodes = false) {
if ($stripCodes) {
$message = Formatter::stripCodes($message);
}
error_log($message); error_log($message);
if ($output) { if ($output) {
self::output($message, $eol); self::output($message, $eol);
@ -112,10 +118,11 @@ abstract class Logger {
* @param string $message * @param string $message
* @param bool $eol * @param bool $eol
* @param bool $output * @param bool $output
* @param bool $stripCodes
*/ */
public static function logInfo($message, $eol = true, $output = true) { public static function logInfo($message, $eol = true, $output = true, $stripCodes = false) {
$message = '[INFO] ' . $message; $message = '[INFO] ' . $message;
self::log($message, $eol, $output); self::log($message, $eol, $output, $stripCodes);
} }
/** /**
@ -124,9 +131,10 @@ abstract class Logger {
* @param string $message * @param string $message
* @param bool $eol * @param bool $eol
* @param bool $output * @param bool $output
* @param bool $stripCodes
*/ */
public static function logWarning($message, $eol = true, $output = true) { public static function logWarning($message, $eol = true, $output = true, $stripCodes = false) {
$message = '[WARNING] ' . $message; $message = '[WARNING] ' . $message;
self::log($message, $eol, $output); self::log($message, $eol, $output, $stripCodes);
} }
} }