Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions qase-behave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Configuration options are described in the
}
}
},
"logging": {
"console": true,
"file": false
},
"environment": "local"
}
```
Expand Down
6 changes: 6 additions & 0 deletions qase-behave/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# qase-behave 2.0.2

## What's new

- Added support for logging configuration. More information about logging configuration can be found in the [docs](../qase-python-commons/docs/LOGGING.md).

# qase-behave 2.0.1

## What's new
Expand Down
7 changes: 7 additions & 0 deletions qase-behave/docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ and command line options override both other values.
| Root suite | `rootSuite` | `QASE_ROOT_SUITE` | `qase-root-suite` | | No | Any string |
| Debug logs | `debug` | `QASE_DEBUG` | `qase-debug` | `False` | No | `True`, `False` |
| Exclude parameters from test results | `excludeParams` | `QASE_EXCLUDE_PARAMS` | `qase-exclude-params` | None, don't exclude any parameters | No | Comma-separated list of parameter names |
| **Logging configuration** |
| Enable/disable console logging output | `logging.console` | `QASE_LOGGING_CONSOLE` | `qase-logging-console` | `true` | No | `true`, `false` |
| Enable/disable file logging output | `logging.file` | `QASE_LOGGING_FILE` | `qase-logging-file` | `false` (true when debug=true) | No | `true`, `false` |
| **Qase TestOps mode configuration** |
| Qase project code | `testops.project` | `QASE_TESTOPS_PROJECT` | `qase-testops-project` | | Yes | Any string |
| Qase API token | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | `qase-testops-api-token` | | Yes | Any string |
Expand Down Expand Up @@ -52,6 +55,10 @@ and command line options override both other values.
"fallback": "report",
"debug": false,
"environment": "local",
"logging": {
"console": true,
"file": false
},
"report": {
"driver": "local",
"connection": {
Expand Down
4 changes: 2 additions & 2 deletions qase-behave/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-behave"
version = "2.0.1"
version = "2.0.2"
description = "Qase Behave Plugin for Qase TestOps and Qase Report"
readme = "README.md"
keywords = ["qase", "behave", "plugin", "testops", "report", "qase reporting", "test observability"]
Expand All @@ -28,7 +28,7 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"qase-python-commons~=4.0.1",
"qase-python-commons~=4.1.0",
"behave>=1.2.6",
"more_itertools",
]
Expand Down
14 changes: 14 additions & 0 deletions qase-behave/src/qase/behave/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,18 @@ def __parse_config(userdata) -> ConfigManager:
cfg_mgr.config.report.connection.set_format(
userdata['qase-report-connection-format'])

if 'qase-logging-console' in userdata:
cfg_mgr.config.logging.set_console(userdata['qase-logging-console'])

if 'qase-logging-file' in userdata:
cfg_mgr.config.logging.set_file(userdata['qase-logging-file'])

# Update logger with final logging options after all options are processed
from qase.commons.logger import LoggingOptions
logging_options = LoggingOptions(
console=cfg_mgr.config.logging.console if cfg_mgr.config.logging.console is not None else True,
file=cfg_mgr.config.logging.file if cfg_mgr.config.logging.file is not None else cfg_mgr.config.debug
)
cfg_mgr.logger = cfg_mgr.logger.__class__(debug=cfg_mgr.config.debug, logging_options=logging_options)

return cfg_mgr
4 changes: 4 additions & 0 deletions qase-pytest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Configuration options are described in the
"captureLogs": true
}
},
"logging": {
"console": true,
"file": false
},
"environment": "local"
}
```
Expand Down
6 changes: 6 additions & 0 deletions qase-pytest/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# qase-pytest 7.0.3

## What's new

- Added support for logging configuration. More information about logging configuration can be found in the [docs](../qase-python-commons/docs/LOGGING.md).

# qase-pytest 7.0.2

## What's new
Expand Down
7 changes: 7 additions & 0 deletions qase-pytest/docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ and command line options override both other values.
| Root suite | `rootSuite` | `QASE_ROOT_SUITE` | `--qase-root-suite` | | No | Any string |
| Debug logs | `debug` | `QASE_DEBUG` | `--qase-debug` | false | No | `true`, `false` |
| Exclude parameters from test results | `excludeParams` | `QASE_EXCLUDE_PARAMS` | `--qase-exclude-params` | None, don't exclude any parameters | No | Comma-separated list of parameter names |
| **Logging configuration** |
| Enable/disable console logging output | `logging.console` | `QASE_LOGGING_CONSOLE` | `--qase-logging-console` | `true` | No | `true`, `false` |
| Enable/disable file logging output | `logging.file` | `QASE_LOGGING_FILE` | `--qase-logging-file` | `false` (true when debug=true) | No | `true`, `false` |
| **Qase TestOps mode configuration** |
| Qase project code | `testops.project` | `QASE_TESTOPS_PROJECT` | `--qase-testops-project` | | Yes | Any string |
| Qase API token | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | `--qase-testops-api-token` | | Yes | Any string |
Expand Down Expand Up @@ -61,6 +64,10 @@ and command line options override both other values.
"fallback": "report",
"debug": false,
"environment": "local",
"logging": {
"console": true,
"file": false
},
"report": {
"driver": "local",
"connection": {
Expand Down
4 changes: 2 additions & 2 deletions qase-pytest/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-pytest"
version = "7.0.2"
version = "7.0.3"
description = "Qase Pytest Plugin for Qase TestOps and Qase Report"
readme = "README.md"
keywords = ["qase", "pytest", "plugin", "testops", "report", "qase reporting", "test observability"]
Expand All @@ -28,7 +28,7 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"qase-python-commons~=4.0.1",
"qase-python-commons~=4.1.0",
"pytest>=7.4.4",
"filelock~=3.12.2",
"more_itertools",
Expand Down
14 changes: 14 additions & 0 deletions qase-pytest/src/qase/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ def setup_config_manager(config):
config_manager.config.testops.run.external_link = ExternalLinkConfig()
config_manager.config.testops.run.external_link.set_link(config.option.__dict__[option])

if option == "qase_logging_console" and config.option.__dict__[option] is not None:
config_manager.config.logging.set_console(config.option.__dict__[option])

if option == "qase_logging_file" and config.option.__dict__[option] is not None:
config_manager.config.logging.set_file(config.option.__dict__[option])

# Update logger with final logging options after all CLI options are processed
from qase.commons.logger import LoggingOptions
logging_options = LoggingOptions(
console=config_manager.config.logging.console if config_manager.config.logging.console is not None else True,
file=config_manager.config.logging.file if config_manager.config.logging.file is not None else config_manager.config.debug
)
config_manager.logger = config_manager.logger.__class__(debug=config_manager.config.debug, logging_options=logging_options)

return config_manager


Expand Down
18 changes: 18 additions & 0 deletions qase-pytest/src/qase/pytest/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,24 @@ def addoptions(parser, group):
help="Define xpass status for passed tests. Default: `passed`"
)

QasePytestOptions.add_option(
parser,
group,
"--qase-logging-console",
dest="qase_logging_console",
type="bool",
help="Enable/disable console logging output"
)

QasePytestOptions.add_option(
parser,
group,
"--qase-logging-file",
dest="qase_logging_file",
type="bool",
help="Enable/disable file logging output"
)

@staticmethod
def add_option(parser, group, option, dest, default=None, type=None, **kwargs):
# We are going to add options that were not added before through the manager
Expand Down
4 changes: 4 additions & 0 deletions qase-robotframework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Configuration options are described in the
}
}
},
"logging": {
"console": true,
"file": false
},
"environment": "local"
}
```
Expand Down
6 changes: 6 additions & 0 deletions qase-robotframework/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# qase-robotframework 4.0.2

## What's new

- Added support for logging configuration. More information about logging configuration can be found in the [docs](../qase-python-commons/docs/LOGGING.md).

# qase-robotframework 4.0.1

## What's new
Expand Down
8 changes: 8 additions & 0 deletions qase-robotframework/docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ Environment variables override the values given in the config file.
| Execution plan path | `executionPlan.path` | `QASE_EXECUTION_PLAN_PATH` | `./build/qase-execution-plan.json` | No | Any string |
| Qase environment | `environment` | `QASE_ENVIRONMENT` | `local` | No | Any string |
| Root suite | `rootSuite` | `QASE_ROOT_SUITE` | | No | Any string |
| Debug logs | `debug` | `QASE_DEBUG` | `False` | No | `True`, `False` |
| Exclude parameters from test results | `excludeParams` | `QASE_EXCLUDE_PARAMS` | None, don't exclude any parameters | No | Comma-separated list of parameter names |
| **Logging configuration** |
| Enable/disable console logging output | `logging.console` | `QASE_LOGGING_CONSOLE` | `true` | No | `true`, `false` |
| Enable/disable file logging output | `logging.file` | `QASE_LOGGING_FILE` | `false` (true when debug=true) | No | `true`, `false` |
| **Qase TestOps mode configuration** |
| Qase project code | `testops.project` | `QASE_TESTOPS_PROJECT` | | Yes | Any string |
| Qase API token | `testops.api.token` | `QASE_TESTOPS_API_TOKEN` | | Yes | Any string |
Expand Down Expand Up @@ -48,6 +52,10 @@ Environment variables override the values given in the config file.
"fallback": "report",
"debug": false,
"environment": "local",
"logging": {
"console": true,
"file": false
},
"report": {
"driver": "local",
"connection": {
Expand Down
4 changes: 2 additions & 2 deletions qase-robotframework/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-robotframework"
version = "4.0.1"
version = "4.0.2"
description = "Qase Robot Framework Plugin"
readme = "README.md"
authors = [{name = "Qase Team", email = "support@qase.io"}]
Expand All @@ -24,7 +24,7 @@ classifiers = [
urls = {"Homepage" = "https://github.com/qase-tms/qase-python/tree/main/qase-robotframework"}
requires-python = ">=3.9"
dependencies = [
"qase-python-commons~=4.0.1",
"qase-python-commons~=4.1.0",
"filelock~=3.12.2",
]

Expand Down
36 changes: 13 additions & 23 deletions qase-robotframework/src/qase/robotframework/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from .types import STATUSES
from .models import *

logger = logging.getLogger("qase-robotframework")


def get_pool_id():
return BuiltIn().get_variable_value('${PABOTQUEUEINDEX}', None)
Expand All @@ -41,15 +39,9 @@ def __init__(self):
self.tests = {}
self.pabot_index = None
self.last_level_flag = None

if config.config.debug:
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
ch.setFormatter(formatter)
logger.addHandler(ch)

# Use centralized logger from config
self.logger = config.logger

def start_suite(self, suite, result):
self.pabot_index = get_pool_id()
Expand All @@ -68,7 +60,7 @@ def start_suite(self, suite, result):
self.__load_run_from_lock()
break
except RuntimeError:
logger.error("Failed to create or read lock file")
self.logger.log_error("Failed to create or read lock file")
else:
self.reporter.start_run()

Expand All @@ -80,15 +72,15 @@ def start_suite(self, suite, result):
self.tests.update(self.__extract_tests_with_suites(suite))

def start_test(self, test, result):
logger.debug("Starting test '%s'", test.name)
self.logger.log_debug(f"Starting test '{test.name}'")

self.runtime.result = Result(title=test.name, signature=test.name)
self.runtime.steps = {}

def end_user_keyword(self, data, implementation, result):
logger.debug("Ending user keyword '%s'", data.name)
self.logger.log_debug(f"Ending user keyword '{data.name}'")

test_metadata = TagParser.parse_tags(result.tags)
test_metadata = TagParser.parse_tags(result.tags, self.logger)

if test_metadata.params:
# Get argument names from the implementation
Expand All @@ -105,12 +97,12 @@ def end_user_keyword(self, data, implementation, result):
self.runtime.result.add_field(Field(key, value))

def end_test(self, test, result):
logger.debug("Finishing test '%s'", test.name)
self.logger.log_debug(f"Finishing test '{test.name}'")

test_metadata = TagParser.parse_tags(test.tags)
test_metadata = TagParser.parse_tags(test.tags, self.logger)

if test_metadata.ignore:
logger.info("Test '%s' is ignored", test.name)
self.logger.log_info(f"Test '{test.name}' is ignored")
return

if test_metadata.qase_ids:
Expand Down Expand Up @@ -163,10 +155,8 @@ def end_test(self, test, result):

self.reporter.add_result(self.runtime.result)

logger.info(
"Finished case result: %s, error: %s",
result.status,
hasattr(result, "message") and result.message or None,
self.logger.log_info(
f"Finished case result: {result.status}, error: {hasattr(result, 'message') and result.message or None}"
)

def close(self):
Expand All @@ -177,7 +167,7 @@ def close(self):
self.reporter.complete_worker()

if not Listener.meta_run_file.exists():
logger.info("complete run executing")
self.logger.log_info("complete run executing")
self.reporter.complete_run()

def __extract_tests_with_suites(self, suite, parent_suites=None):
Expand Down
Loading