Skip to content
Open
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
13 changes: 7 additions & 6 deletions src/fastcs/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ class Tracer:
Note: The global logger level must be set to ``TRACE`` for the messages to be logged

Example usage:
>>> controller.ramp_rate.enable_tracing()
>>> controller.ramp_rate.disable_tracing()
>>> controller.connection.enable_tracing()
>>> controller.connection.add_tracing_filter("query", "V?")
>>> controller.connection.remove_tracing_filter("query", "V?")
>>> controller.connection.disable_tracing()
.. code-block:: python
controller.ramp_rate.enable_tracing()
controller.ramp_rate.disable_tracing()
controller.connection.enable_tracing()
controller.connection.add_tracing_filter("query", "V?")
controller.connection.remove_tracing_filter("query", "V?")
controller.connection.disable_tracing()

:param name: The name of the logger. Attached to log messages as ``logger_name``.

Expand Down
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

import pytest
from aioca import purge_channel_caches
from loguru import logger as _logger
from softioc import builder

from fastcs.attributes import AttrR, AttrRW, AttrW
from fastcs.datatypes import Bool, Float, Int, String
from fastcs.launch import build_controller_api
from fastcs.logging import LogLevel, configure_logging
from fastcs.transport.tango.dsr import register_dev
from tests.assertable_controller import MyTestAttributeIORef, MyTestController
from tests.example_p4p_ioc import run as _run_p4p_ioc
Expand Down Expand Up @@ -86,6 +88,11 @@ def _run_ioc_as_subprocess(
error_queue: multiprocessing.Queue,
stdout_queue: multiprocessing.Queue,
):
configure_logging(LogLevel.INFO)
# we need to capture log messages from transport
logger = _logger.bind(logger_name="fastcs.transport.epics.ca.transport")
logger.add(print) # forward log messages to stdout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all that is required

diff --git a/tests/conftest.py b/tests/conftest.py
index df850933..0af1e703 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -15,13 +15,12 @@ from uuid import uuid4
 
 import pytest
 from aioca import purge_channel_caches
-from loguru import logger as _logger
 from softioc import builder
 
 from fastcs.attributes import AttrR, AttrRW, AttrW
 from fastcs.datatypes import Bool, Float, Int, String
 from fastcs.launch import build_controller_api
-from fastcs.logging import LogLevel, configure_logging
+from fastcs.logging import logger
 from fastcs.transport.tango.dsr import register_dev
 from tests.assertable_controller import MyTestAttributeIORef, MyTestController
 from tests.example_p4p_ioc import run as _run_p4p_ioc
@@ -88,10 +87,9 @@ def _run_ioc_as_subprocess(
     error_queue: multiprocessing.Queue,
     stdout_queue: multiprocessing.Queue,
 ):
-    configure_logging(LogLevel.INFO)
     # we need to capture log messages from transport
-    logger = _logger.bind(logger_name="fastcs.transport.epics.ca.transport")
     logger.add(print)  # forward log messages to stdout
+    logger.enable("fastcs")
 
     try:
         from pytest_cov.embed import cleanup_on_sigterm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still hangs on my end with this fix

try:
from pytest_cov.embed import cleanup_on_sigterm
except ImportError:
Expand Down Expand Up @@ -127,7 +134,7 @@ def run_ioc_as_subprocess(
start_time = time.monotonic()
while True:
try:
if "Running FastCS IOC" in (
if "Running IOC" in (
stdout_queue.get(timeout=ioc_startup_timeout) # type: ignore
):
stdout_queue.get() # get the newline
Expand Down
Loading