Skip to content

Commit

Permalink
Emojis as log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Commifreak committed Aug 16, 2023
1 parent c5b1a13 commit 046f3b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/include/ABHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class ABHelper {
* @var array Store some temporary data about containers, which should skipped during start routine
*/
private static $skipStartContainers = [];

private static $emojiLevels = [
self::LOGLEVEL_INFO => 'ℹ️',
self::LOGLEVEL_WARN => '⚠️',
self::LOGLEVEL_ERR => ''
];
public static $currentContainerName;

public static $targetLogLevel = '';
Expand Down Expand Up @@ -98,13 +104,8 @@ public static function backupLog(string $msg, string $level = self::LOGLEVEL_INF
}

$section = empty(self::$currentContainerName) ? 'Main' : self::$currentContainerName;
$emojiLevel = [
self::LOGLEVEL_INFO => 'ℹ️',
self::LOGLEVEL_WARN => '⚠️',
self::LOGLEVEL_ERR => ''
];

$logLine = ($skipDate ? '' : "[" . date("d.m.Y H:i:s") . "][" . ($emojiLevel[$level] ?? $level) . "][$section]") . " $msg" . ($newLine ? "\n" : '');
$logLine = ($skipDate ? '' : "[" . date("d.m.Y H:i:s") . "][" . (self::$emojiLevels[$level] ?? $level) . "][$section]") . " $msg" . ($newLine ? "\n" : '');

if ($level != self::LOGLEVEL_DEBUG) {
file_put_contents(ABSettings::$tempFolder . '/' . ABSettings::$logfile, $logLine, FILE_APPEND);
Expand Down

0 comments on commit 046f3b5

Please sign in to comment.