No Yii2::debug() shown in the Codecept -vvv output

Open
#95 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
testing-qa

Research direction

Start with src/Codeception/Lib/Connector/Yii2/Logger.php and its level check, then inspect how codecept run -vv, -vvv, and --debug determine logging verbosity. The change is complete when Yii2 debug output appears at the intended verbosity without unexpectedly increasing normal output for existing users.

Written by the indexing model from the issue text.

Description

bug
What are you trying to achieve?

I would like to see the Yii2::debug() output in the codecept run -vvv <filename> output.

What do you get instead?

Only the Yii::info, Yii::warning and Yii::error outputs are shown.

Provide console output if related. Use -vvv mode for more details.


  [application] 'Info: Testing info Output in Codecept'
  [application] 'Warning: Testing Warning Output in Codecept'
  [application] 'Error: Testing Error Output in Codecept'

Provide test source code if related

    \Yii::trace("Trace: Testing Trace in Codecept");
    \Yii::debug("Debug: Testing Debugging in Codecept");
    \Yii::info("Info: Testing info Output in Codecept");
    \Yii::warning("Warning: Testing Warning Output in Codecept");
    \Yii::error("Error: Testing Error Output in Codecept");
Details
  • PHP Version: Tested with v7.4
  • Operating System: Linux
  • Installation type: Composer
  • Suite configuration:

class_name: UnitTester
modules:
    enabled:
      - Asserts
      - Filesystem
      - Yii2:
            part: [orm, email]

The issue can be resolved if I directly edit vendor/codeception/base/src/Codeception/Lib/Connector/Yii2/Logger.php and in the levels check

if (!in_array($level, [
    \yii\log\Logger::LEVEL_INFO,
    \yii\log\Logger::LEVEL_WARNING,
    \yii\log\Logger::LEVEL_ERROR,
])) {
    return;
}

I add in \yii\log\Logger::LEVEL_TRACE,

I suspect it's not in there because by default it would be rather verbose.
Changing it now could also overwhelm existing users.

The reason I would like it in there is because when I'm debugging an issue and using Unit Tests to do so, it's nicer to use Yii::debug() for getting the information I need. I've spent ages setting up a unit test for a specific scenario only to find there's some edge case I need more info on to investigate.
However I'm currently forced to use \Yii::info() to output that information and that is also output in the web debugger and in our staging environment log files and breaks the semantics of debug versus info

Ideally the Trace level would ONLY be included if -vvv (3x verbosity) was used and not -vv (2x verbosity) or if --debug.

However I'm not sure how to test that when the Logger->log() method is being called, so whilst I can submit a pull request simply adding the extra level, I suspect that's not ideal for existing users who might not want the extra verbosity.

Alternatively if someone can point out how I can specify my own logger so I can fork the existing one (or use container definitions to remap to my own)? Or allow it to only show if there's a config entry, like as part of the Yii2 module .yml, then that would be ideal.

Dominant language
PHP
Stars
19
Forks
43
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Codeception/module-yii2

All issues in Codeception/module-yii2

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.