Skip to content

Commit

Permalink
Fixes #20: Remove custom log level "success" (#28)
Browse files Browse the repository at this point in the history
* Remove custom log level "success"

* Test 3.x branch
  • Loading branch information
greg-1-anderson committed Apr 5, 2022
1 parent e95baff commit 12d16fd
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -4,10 +4,10 @@
on:
pull_request:
branches:
- main
- 3.x
push:
branches:
- main
- 3.x

name: CI

Expand Down
25 changes: 0 additions & 25 deletions src/ConsoleLogLevel.php

This file was deleted.

3 changes: 0 additions & 3 deletions src/LogOutputStyler.php
Expand Up @@ -13,7 +13,6 @@
class LogOutputStyler extends UnstyledLogOutputStyler
{
const TASK_STYLE_INFO = 'fg=white;bg=cyan;options=bold';
const TASK_STYLE_SUCCESS = 'fg=white;bg=green;options=bold';
const TASK_STYLE_WARNING = 'fg=black;bg=yellow;options=bold;';
const TASK_STYLE_ERROR = 'fg=white;bg=red;options=bold';

Expand All @@ -29,7 +28,6 @@ class LogOutputStyler extends UnstyledLogOutputStyler
LogLevel::NOTICE => self::TASK_STYLE_INFO,
LogLevel::INFO => self::TASK_STYLE_INFO,
LogLevel::DEBUG => self::TASK_STYLE_INFO,
ConsoleLogLevel::SUCCESS => self::TASK_STYLE_SUCCESS,
];
protected $messageStyles = [
LogLevel::EMERGENCY => self::TASK_STYLE_ERROR,
Expand All @@ -40,7 +38,6 @@ class LogOutputStyler extends UnstyledLogOutputStyler
LogLevel::NOTICE => '',
LogLevel::INFO => '',
LogLevel::DEBUG => '',
ConsoleLogLevel::SUCCESS => '',
];

public function __construct($labelStyles = [], $messageStyles = [])
Expand Down
5 changes: 0 additions & 5 deletions src/LogOutputStylerInterface.php
Expand Up @@ -64,11 +64,6 @@ public function createOutputWrapper(OutputInterface $output);
*/
public function log($output, $level, $message, $context);

/**
* Print a success message.
*/
public function success($output, $level, $message, $context);

/**
* Print an error message. Used when log level is:
* - LogLevel::EMERGENCY
Expand Down
9 changes: 1 addition & 8 deletions src/Logger.php
Expand Up @@ -51,7 +51,6 @@ class Logger extends AbstractLogger implements StylableLoggerInterface, Settable
LogLevel::NOTICE => 'note',
LogLevel::INFO => 'note',
LogLevel::DEBUG => 'note',
ConsoleLogLevel::SUCCESS => 'success',
];

/**
Expand Down Expand Up @@ -152,6 +151,7 @@ public function log($level, string|\Stringable $message, array $context = []): v
// to style log messages at a custom log level that might not
// be available in all loggers. If the logger does not recognize
// the log level, then it is treated like the original log level.
// SUCCESS is no longer a supported log level
if (array_key_exists('_level', $context) && array_key_exists($context['_level'], $this->verbosityLevelMap)) {
$level = $context['_level'];
}
Expand Down Expand Up @@ -193,11 +193,6 @@ protected function doLog($outputStreamWrapper, $level, $message, $context)
);
}

public function success($message, array $context = array())
{
$this->log(ConsoleLogLevel::SUCCESS, $message, $context);
}

// The functions below could be eliminated if made `protected` intead
// of `private` in ConsoleLogger

Expand All @@ -220,7 +215,6 @@ public function success($message, array $context = array())
LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
ConsoleLogLevel::SUCCESS => OutputInterface::VERBOSITY_NORMAL,
];

/**
Expand All @@ -239,7 +233,6 @@ public function success($message, array $context = array())
LogLevel::NOTICE => self::ERROR,
LogLevel::INFO => self::ERROR,
LogLevel::DEBUG => self::ERROR,
ConsoleLogLevel::SUCCESS => self::ERROR,
];

/**
Expand Down
8 changes: 0 additions & 8 deletions src/UnstyledLogOutputStyler.php
Expand Up @@ -46,14 +46,6 @@ public function log($output, $level, $message, $context)
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
}

/**
* {@inheritdoc}
*/
public function success($output, $level, $message, $context)
{
return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 0 additions & 5 deletions tests/LogMethodTests.php
Expand Up @@ -47,9 +47,4 @@ function testDebug() {
$this->assertEquals(' [debug] Counter incremented.', $outputText);
}

function testSuccess() {
$this->logger->success('It worked!');
$outputText = rtrim($this->output->fetch());
$this->assertEquals(' [success] It worked!', $outputText);
}
}
21 changes: 0 additions & 21 deletions tests/LoggerVerbosityAndStyleTests.php
Expand Up @@ -116,20 +116,6 @@ public static function logTestValues()
'Counter incremented.',
'',
],
[
'\Consolidation\Log\UnstyledLogOutputStyler',
$TEST_ALL_LOG_LEVELS,
ConsoleLogLevel::SUCCESS,
'It worked!',
' [success] It worked!',
],
[
'\Consolidation\Log\LogOutputStyler',
OutputInterface::VERBOSITY_NORMAL,
ConsoleLogLevel::SUCCESS,
'It worked!',
' [success] It worked!',
],
[
'\Consolidation\Log\SymfonyLogOutputStyler',
OutputInterface::VERBOSITY_DEBUG,
Expand Down Expand Up @@ -158,13 +144,6 @@ public static function logTestValues()
'Counter incremented.',
"\n ! [NOTE] Counter incremented.",
],
[
'\Consolidation\Log\SymfonyLogOutputStyler',
OutputInterface::VERBOSITY_NORMAL,
ConsoleLogLevel::SUCCESS,
'It worked!',
"\n [OK] It worked!",
],
]);
}

Expand Down

0 comments on commit 12d16fd

Please sign in to comment.