final class ConsoleLogger

Supports all operations related to writing output to console.

Constants

BG_BLACK

Value for background black.

BG_RED

Value for background red.

BG_GREEN

Value for background green.

BG_YELLOW

Value for background yellow.

BG_BLUE

Value for background blue.

BG_MAGENTA

Value for background magenta.

BG_CYAN

Value for background cyan.

BG_LIGHT_GREY

Value for background light grey

TEXT_BLACK

Value for text black.

TEXT_WHITE

Value for text white.

TEXT_DARK_GREY

Value for text dark grey.

TEXT_RED

Value for text red.

TEXT_GREEN

Value for text green.

TEXT_BROWN

Value for text brown.

TEXT_YELLOW

Value for text yellow.

TEXT_BLUE

Value for text blue.

TEXT_MAGENTA

Value for text magenta.

TEXT_CYAN

Value for text cyan.

TEXT_LIGHT_CYAN

Value for text light cyan.

TEXT_LIGHT_GREY

Value for text light grey.

TEXT_LIGHT_RED

Value for text light red.

TEXT_LIGHT_GREEN

Value for text light green.

TEXT_LIGHT_BLUE

Value for text light blue.

TEXT_LIGHT_MAGENTA

Value for text light magenta.

Properties

static private OutputInterface|null $output

Supports ability to log information to console.

Methods

static void
consoleLog(string $output)

Performs actual action of writing output to console with specified background color, text color, and message.

static string
fixBackgroundColor(string $level)

Fixes background color when invalid background color is set for originating message.

static bool
hasConstant(string $value, string $type)

Checks if value for background color or text color matches list of available constants.

static void
log(string $message, string $level = Logger::INFO, string $background = self::BG_GREEN, string $text = self::TEXT_LIGHT_GREY)

Generates output messages for console commands.

static void
setOutput(OutputInterface $output)

Enables output for symfony.

Details

at line 78
static private void consoleLog(string $output)

Performs actual action of writing output to console with specified background color, text color, and message.

Parameters

string $output

The output string for the console.

Return Value

void

at line 91
static private string fixBackgroundColor(string $level)

Fixes background color when invalid background color is set for originating message.

Parameters

string $level

The severity level passed as a parameter to the self::log function.

Return Value

string

The correct background color based on severity level.

at line 134
static private bool hasConstant(string $value, string $type)

Checks if value for background color or text color matches list of available constants.

Parameters

string $value

The value of constant passed into info()

string $type

The type of value to determine what type of constant.

Return Value

bool

True if $value matches a available constant for background color or text color.

at line 166
static void log(string $message, string $level = Logger::INFO, string $background = self::BG_GREEN, string $text = self::TEXT_LIGHT_GREY)

Generates output messages for console commands.

Parameters

string $message

The message we want to show.

string $level

The level of severity for log file. The valid levels are info, debug, warning, error, critical, alert, and emergency.

string $background

The background color. This function supports black, red, green, yellow, blue, magenta, cyan, and light-grey

string $text

The color of the text. This function supports black, white, dark-grey, red, green, brown, blue, magenta, cyan, light-cyan, light-grey, light-red, light green, light-blue, and light-magenta.

Return Value

void

at line 215
static void setOutput(OutputInterface $output)

Enables output for symfony.

Parameters

OutputInterface $output

Symfony output.

Return Value

void