- How do I install phrity/logger-console in a Laravel application?
- Install it with Composer using composer require phrity/logger-console. Then instantiate Phrity\Logger\Console\ConsoleLogger where you need console output, such as in an Artisan command or a test helper. It is PSR-3 compatible, so you can use it alongside Laravel's existing Monolog logging rather than replacing it.
- Is phrity/logger-console compatible with Laravel's Monolog logging system?
- Yes, because it implements PSR-3, the same logging standard Laravel uses through Monolog. It can supplement Monolog by writing CLI or test output to the console while Monolog continues handling file, database, or external log channels. Plan routing deliberately if you want both loggers active in the same command.
- How do I control verbosity in a Laravel Artisan command with phrity/logger-console?
- Set the verbosity in the ConsoleLogger constructor using Verbosity::Quiet, Normal, Verbose, VeryVerbose, or Debug. You can also enable cliOptions so the logger reads -q, -v, -vv, -vvv, and --debug from the console input. In Artisan commands, expose the same flags and map them to the verbosity level you want.
- Can I customize the console log format in phrity/logger-console?
- Yes, pass a format string to ConsoleLogger using placeholders such as {datetime}, {level}, {message}, and {context}. The default format is {datetime} [{level}] {message}, but you can add context or change the layout for your CLI tool. This helps standardize log lines across Artisan commands and test runs.
- Does phrity/logger-console support Laravel 9 and newer?
- The package requires PHP 8.1 or later, and the current 1.0 release targets that baseline. Laravel 9 and newer applications commonly meet this PHP requirement, making it a reasonable fit for modern Artisan and testing workflows. For older Laravel versions, verify the PHP constraint and dependency compatibility before installing.
- How is phrity/logger-console different from Monolog in Laravel?
- Monolog is Laravel's general-purpose logging stack with handlers for files, databases, and external services. phrity/logger-console is a lightweight PSR-3 logger focused on console output, verbosity levels, and readable CLI formatting. Use it as a CLI-specific supplement to Monolog, not as a full replacement for persistent production logs.
- Can I use phrity/logger-console for Laravel tests and PHPUnit debugging?
- Yes, it is aimed at local tests and console applications where writing structured output is more useful than digging through log files. You can replace dd or var_dump calls with PSR-3 log messages at appropriate levels. Keep test verbosity controlled so CI output stays readable and failures remain easy to diagnose.
- What CLI flags does phrity/logger-console support for verbosity?
- When cliOptions is enabled, it recognizes --quiet or -q, --verbose=1 or -v, --verbose=2 or -vv, and --verbose=3, -vvv, or --debug. These map to the package's Quiet through Debug verbosity levels. This lets developers change console log detail from the command line without editing application code.
- Is phrity/logger-console safe for production Laravel applications?
- It is primarily intended for local tests, debugging, and CLI applications, not as a replacement for Laravel's production logging stack. The package has limited public adoption, so validate it in staging and review its phrity/util dependencies before relying on it. For production observability, keep Monolog or another persistent log channel in place.
- How should I handle conflicts between ConsoleLogger verbosity and Laravel APP_DEBUG?
- Treat ConsoleLogger verbosity as a CLI output control and APP_DEBUG as an application error-display setting, rather than letting them duplicate each other. Reserve ConsoleLogger for command and test contexts where console detail is useful, and route persistent application logs through Monolog. Define this boundary clearly so developers know which setting to change when debugging.