Skip to content

Commit 270f8d0

Browse files
update
1 parent 2384f54 commit 270f8d0

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

Capsule/Logger.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tamedevelopers\Support\Capsule;
66

7+
use Tamedevelopers\Support\Str;
78
use Symfony\Component\Console\Output\ConsoleOutput;
89
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
910

@@ -28,8 +29,7 @@
2829
*
2930
* Help-like layout:
3031
* Logger::helpHeader('blog-store');
31-
* Logger::helpItem('blog-store', 'activities', null,
32-
* 'Update Blog Views and Clicks and Delete the From Blog Data to reserve DB Storage Space');
32+
* Logger::helpItem('blog-store', 'activities', null, 'Description', 30, false, ['green', 'yellow']);
3333
*
3434
* @package Tamedevelopers\Database\Capsule
3535
*/
@@ -67,7 +67,7 @@ protected static function registerDefaultStyles(ConsoleOutput $output): void
6767
// existing
6868
'success' => ['bright-green', null, ['bold']],
6969
'error' => ['bright-red', null, ['bold']],
70-
'info' => ['bright-cyan', null, []],
70+
'info' => ['bright-cyan', null, ['bold']],
7171

7272
// extras
7373
'yellow' => ['yellow', null, ['bold']],
@@ -135,10 +135,17 @@ public static function segments(array $segments, string $separator = ''): string
135135

136136
/**
137137
* Print a group/section header (e.g., a namespace or package name).
138+
* Accepts optional style/color while keeping backward compatibility.
139+
* - Old: helpHeader('blog-store', true) => STDERR with default 'title' style
140+
* - New: helpHeader('blog-store', 'green', true)
138141
*/
139-
public static function helpHeader(string $title, bool $stderr = false): void
142+
public static function helpHeader(string $title, $style = 'title', bool $stderr = false): void
140143
{
141-
static::writeln("<title>{$title}</title>", $stderr);
144+
if (is_bool($style)) {
145+
$stderr = $style;
146+
$style = 'title';
147+
}
148+
static::writeln("<{$style}>{$title}</{$style}>", $stderr);
142149
}
143150

144151
/**
@@ -153,19 +160,22 @@ public static function helpHeader(string $title, bool $stderr = false): void
153160
*/
154161
public static function helpItem(
155162
string $namespace,
156-
string $methodYellow,
163+
string $method,
157164
?string $keyGreen,
158165
string $description,
159166
int $pad = 35,
160-
bool $stderr = false
167+
bool $stderr = false,
168+
array $colorSegments = ['green', 'green']
161169
): void {
170+
$colorSegments = Str::flatten($colorSegments);
171+
162172
// Build colored label left side
163173
$label = self::segments([
164-
['text' => $namespace . ':', 'style' => 'green'],
165-
['text' => $methodYellow, 'style' => 'green'],
174+
['text' => $namespace . ':', 'style' => $colorSegments[0] ?: 'green'],
175+
['text' => $method, 'style' => $colorSegments[1] ?: 'green'],
166176
]);
167177

168-
if ($keyGreen !== null && $keyGreen !== '') {
178+
if (!empty($keyGreen)) {
169179
$label .= ' ' . self::segments([
170180
['text' => $keyGreen, 'style' => 'key'],
171181
]);
@@ -192,19 +202,18 @@ protected static function visibleLength(string $formatted): int
192202
}
193203

194204
// ---- Simple level helpers (kept for BC) ----
195-
196205
public static function info(string $message): void
197206
{
198-
static::writeln("<info>{$message}</info>");
207+
static::writeln("\n <info> INFO </info> {$message}");
199208
}
200209

201210
public static function success(string $message): void
202211
{
203-
static::writeln("<success>{$message}</success>");
212+
static::writeln("\n <success> SUCCESS </success> {$message}");
204213
}
205214

206215
public static function error(string $message): void
207216
{
208-
static::writeln("<error>{$message}</error>");
217+
static::writeln("\n <error> ERROR </error> {$message}");
209218
}
210219
}

0 commit comments

Comments
 (0)