diff --git a/docs/snippets/static14.py b/docs/snippets/static14.py
index 2e1824eab..fb794b199 100644
--- a/docs/snippets/static14.py
+++ b/docs/snippets/static14.py
@@ -10,13 +10,11 @@
from fastcs.controllers import Controller
from fastcs.datatypes import Enum, Float, Int, String
from fastcs.launch import FastCS
-from fastcs.logging import bind_logger, configure_logging
+from fastcs.logging import configure_logging, logger
from fastcs.methods import command, scan
from fastcs.transports.epics import EpicsGUIOptions, EpicsIOCOptions
from fastcs.transports.epics.ca import EpicsCATransport
-logger = bind_logger(__name__)
-
NumberT = TypeVar("NumberT", int, float)
@@ -33,8 +31,6 @@ class TemperatureControllerAttributeIO(
def __init__(self, connection: IPConnection, suffix: str = ""):
super().__init__()
- self.logger = bind_logger(__class__.__name__)
-
self._connection = connection
self._suffix = suffix
@@ -49,7 +45,7 @@ async def send(
) -> None:
command = f"{attr.io_ref.name}{self._suffix}={attr.dtype(value)}"
- self.logger.info("Sending attribute value", command=command, attribute=attr)
+ logger.info("Sending attribute value", command=command, attribute=attr)
await self._connection.send_command(f"{command}\r\n")
diff --git a/docs/snippets/static15.py b/docs/snippets/static15.py
index 4df6934c2..0246d2cb0 100644
--- a/docs/snippets/static15.py
+++ b/docs/snippets/static15.py
@@ -10,13 +10,11 @@
from fastcs.controllers import Controller
from fastcs.datatypes import Enum, Float, Int, String
from fastcs.launch import FastCS
-from fastcs.logging import LogLevel, bind_logger, configure_logging
+from fastcs.logging import LogLevel, configure_logging, logger
from fastcs.methods import command, scan
from fastcs.transports.epics import EpicsGUIOptions, EpicsIOCOptions
from fastcs.transports.epics.ca import EpicsCATransport
-logger = bind_logger(__name__)
-
NumberT = TypeVar("NumberT", int, float)
@@ -33,8 +31,6 @@ class TemperatureControllerAttributeIO(
def __init__(self, connection: IPConnection, suffix: str = ""):
super().__init__()
- self.logger = bind_logger(__class__.__name__)
-
self._connection = connection
self._suffix = suffix
@@ -52,7 +48,7 @@ async def send(
) -> None:
command = f"{attr.io_ref.name}{self._suffix}={attr.dtype(value)}"
- self.logger.info("Sending attribute value", command=command, attribute=attr)
+ logger.info("Sending attribute value", command=command, attribute=attr)
await self._connection.send_command(f"{command}\r\n")
diff --git a/docs/tutorials/static-drivers.md b/docs/tutorials/static-drivers.md
index 09c0a975a..f881444e7 100644
--- a/docs/tutorials/static-drivers.md
+++ b/docs/tutorials/static-drivers.md
@@ -409,10 +409,7 @@ DEMO:R1:Enabled_RBV Off
FastCS has convenient logging support to provide status and metrics from the
application. To enable logging from the core framework call `configure_logging` with no
-arguments (the default logging level is INFO). To log messages from a driver, either
-import the singleton `logger` directly, or to provide more context to the message, call
-`bind_logger` with a name (usually either the name of the module or the name of the
-class).
+arguments (the default logging level is INFO). To log messages from a driver, import the singleton `logger` directly.
Create a module-level logger to log status of the application start up. Create a class
logger for `TemperatureControllerAttributeIO` to log the commands it sends.
@@ -421,7 +418,7 @@ logger for `TemperatureControllerAttributeIO` to log the commands it sends.
:class: dropdown, hint
:::{literalinclude} /snippets/static14.py
-:emphasize-lines: 15,20-21,53-55,116,123
+:emphasize-lines: 13,51,113,120
:::
::::
diff --git a/src/fastcs/attributes/attr_r.py b/src/fastcs/attributes/attr_r.py
index 59a2f227a..95a9fa383 100644
--- a/src/fastcs/attributes/attr_r.py
+++ b/src/fastcs/attributes/attr_r.py
@@ -8,10 +8,7 @@
from fastcs.attributes.attribute_io_ref import AttributeIORefT
from fastcs.attributes.util import AttrValuePredicate, PredicateEvent
from fastcs.datatypes import DataType, DType_T
-from fastcs.logging import bind_logger
-
-logger = bind_logger(logger_name=__name__)
-
+from fastcs.logging import logger
AttrIOUpdateCallback = Callable[["AttrR[DType_T, Any]"], Awaitable[None]]
"""An AttributeIO callback that takes an AttrR and updates its value"""
diff --git a/src/fastcs/attributes/attr_rw.py b/src/fastcs/attributes/attr_rw.py
index deff02783..5f0c2edbd 100644
--- a/src/fastcs/attributes/attr_rw.py
+++ b/src/fastcs/attributes/attr_rw.py
@@ -3,9 +3,6 @@
from fastcs.attributes.attribute import AttributeAccessMode
from fastcs.attributes.attribute_io_ref import AttributeIORefT
from fastcs.datatypes import DataType, DType_T
-from fastcs.logging import bind_logger
-
-logger = bind_logger(logger_name=__name__)
class AttrRW(AttrR[DType_T, AttributeIORefT], AttrW[DType_T, AttributeIORefT]):
diff --git a/src/fastcs/attributes/attr_w.py b/src/fastcs/attributes/attr_w.py
index 4532364a5..fa2b3d894 100644
--- a/src/fastcs/attributes/attr_w.py
+++ b/src/fastcs/attributes/attr_w.py
@@ -5,10 +5,7 @@
from fastcs.attributes.attribute import Attribute, AttributeAccessMode
from fastcs.attributes.attribute_io_ref import AttributeIORefT
from fastcs.datatypes import DataType, DType_T
-from fastcs.logging import bind_logger
-
-logger = bind_logger(logger_name=__name__)
-
+from fastcs.logging import logger
AttrOnPutCallback = Callable[["AttrW[DType_T, Any]", DType_T], Awaitable[None]]
"""Callbacks to be called when the setpoint of an attribute is changed"""
diff --git a/src/fastcs/attributes/attribute.py b/src/fastcs/attributes/attribute.py
index ae6e3852d..ca4955b53 100644
--- a/src/fastcs/attributes/attribute.py
+++ b/src/fastcs/attributes/attribute.py
@@ -4,11 +4,8 @@
from fastcs.attributes.attribute_io_ref import AttributeIORefT
from fastcs.datatypes import DataType, DType, DType_T
-from fastcs.logging import bind_logger
from fastcs.tracer import Tracer
-logger = bind_logger(logger_name=__name__)
-
AttributeAccessMode = Literal["r", "w", "rw"]
diff --git a/src/fastcs/control_system.py b/src/fastcs/control_system.py
index cae16b77d..e992521cb 100644
--- a/src/fastcs/control_system.py
+++ b/src/fastcs/control_system.py
@@ -8,13 +8,12 @@
from IPython.terminal.embed import InteractiveShellEmbed
from fastcs.controllers import BaseController, Controller
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods import ScanCallback
from fastcs.tracer import Tracer
from fastcs.transports import ControllerAPI, Transport
tracer = Tracer(name=__name__)
-logger = bind_logger(logger_name=__name__)
class FastCS:
diff --git a/src/fastcs/controllers/base_controller.py b/src/fastcs/controllers/base_controller.py
index 0e5fc1de0..472573526 100755
--- a/src/fastcs/controllers/base_controller.py
+++ b/src/fastcs/controllers/base_controller.py
@@ -6,12 +6,10 @@
from typing import _GenericAlias, get_args, get_origin, get_type_hints # type: ignore
from fastcs.attributes import AnyAttributeIO, Attribute, AttrR, AttrW, HintedAttribute
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods import Command, Scan, UnboundCommand, UnboundScan
from fastcs.tracer import Tracer
-logger = bind_logger(logger_name=__name__)
-
class BaseController(Tracer):
"""Base class for controllers
diff --git a/src/fastcs/logging/__init__.py b/src/fastcs/logging/__init__.py
index ba11b087e..567de1d8a 100644
--- a/src/fastcs/logging/__init__.py
+++ b/src/fastcs/logging/__init__.py
@@ -7,7 +7,7 @@
from ._graylog import GraylogStaticFields as GraylogStaticFields
from ._graylog import parse_graylog_env_fields as parse_graylog_env_fields
from ._graylog import parse_graylog_static_fields as parse_graylog_static_fields
-from ._logging import Logger, LogLevel, _configure_logger
+from ._logging import LogLevel, _configure_logger
logger = _logger.bind(logger_name="fastcs")
"""FastCS logger
@@ -57,18 +57,6 @@
"""
-def bind_logger(logger_name: str) -> Logger:
- """Create a wrapper of the singleton fastcs logger with the given name bound
-
- The name will be displayed in all log messages from the returned wrapper.
-
- See the docstring for ``fastcs.logging.logger`` for more information.
-
- """
-
- return logger.bind(logger_name=logger_name)
-
-
def configure_logging(
level: LogLevel = LogLevel.INFO,
graylog_endpoint: GraylogEndpoint | None = None,
diff --git a/src/fastcs/logging/_logging.py b/src/fastcs/logging/_logging.py
index a4358426b..6586c983d 100644
--- a/src/fastcs/logging/_logging.py
+++ b/src/fastcs/logging/_logging.py
@@ -108,7 +108,8 @@ def format_record(record) -> str:
return f"""\
[{time} {record["level"].name[0]}] \
-{record["message"]:<80} \
+{record["message"]} \
+{f"[{record['file'].path}:{record['line']}]":<80} \
[{name}] \
{extras}
{{exception}}\
diff --git a/src/fastcs/methods/command.py b/src/fastcs/methods/command.py
index 87d0e0b1d..5259e4b64 100644
--- a/src/fastcs/methods/command.py
+++ b/src/fastcs/methods/command.py
@@ -2,13 +2,12 @@
from types import MethodType
from typing import TYPE_CHECKING
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods.method import Controller_T, Method
if TYPE_CHECKING:
from fastcs.controllers import BaseController # noqa: F401
-logger = bind_logger(logger_name=__name__)
UnboundCommandCallback = Callable[[Controller_T], Coroutine[None, None, None]]
"""A Command callback that is unbound and must be called with a `Controller` instance"""
diff --git a/src/fastcs/methods/scan.py b/src/fastcs/methods/scan.py
index a20b7e944..5701e79df 100644
--- a/src/fastcs/methods/scan.py
+++ b/src/fastcs/methods/scan.py
@@ -2,13 +2,12 @@
from types import MethodType
from typing import TYPE_CHECKING
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods.method import Controller_T, Method
if TYPE_CHECKING:
from fastcs.controllers import BaseController # noqa: F401
-logger = bind_logger(logger_name=__name__)
UnboundScanCallback = Callable[[Controller_T], Coroutine[None, None, None]]
"""A Scan callback that is unbound and must be called with a `Controller` instance"""
diff --git a/src/fastcs/transports/controller_api.py b/src/fastcs/transports/controller_api.py
index 3a13fae0a..b4242ae26 100644
--- a/src/fastcs/transports/controller_api.py
+++ b/src/fastcs/transports/controller_api.py
@@ -4,13 +4,11 @@
from dataclasses import dataclass, field
from fastcs.attributes import Attribute, AttributeIORef, AttrR
-from fastcs.logging import bind_logger
from fastcs.methods import Command, Scan, ScanCallback
from fastcs.tracer import Tracer
from fastcs.util import ONCE
tracer = Tracer(name=__name__)
-logger = bind_logger(logger_name=__name__)
@dataclass
diff --git a/src/fastcs/transports/epics/ca/ioc.py b/src/fastcs/transports/epics/ca/ioc.py
index fbaaa993f..fd8bf2274 100644
--- a/src/fastcs/transports/epics/ca/ioc.py
+++ b/src/fastcs/transports/epics/ca/ioc.py
@@ -9,7 +9,7 @@
from fastcs.attributes import AttrR, AttrRW, AttrW
from fastcs.datatypes import DataType, DType_T
from fastcs.datatypes.waveform import Waveform
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods import Command
from fastcs.tracer import Tracer
from fastcs.transports.controller_api import ControllerAPI
@@ -28,7 +28,6 @@
tracer = Tracer(name=__name__)
-logger = bind_logger(logger_name=__name__)
class EpicsCAIOC:
diff --git a/src/fastcs/transports/epics/ca/transport.py b/src/fastcs/transports/epics/ca/transport.py
index 13f072314..71ed3adac 100644
--- a/src/fastcs/transports/epics/ca/transport.py
+++ b/src/fastcs/transports/epics/ca/transport.py
@@ -4,7 +4,7 @@
from softioc import softioc
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.transports.controller_api import ControllerAPI
from fastcs.transports.epics import (
EpicsDocsOptions,
@@ -16,8 +16,6 @@
from fastcs.transports.epics.gui import EpicsGUI
from fastcs.transports.transport import Transport
-logger = bind_logger(logger_name=__name__)
-
@dataclass
class EpicsCATransport(Transport):
diff --git a/src/fastcs/transports/epics/gui.py b/src/fastcs/transports/epics/gui.py
index 9bc47f7bd..c4e69b093 100644
--- a/src/fastcs/transports/epics/gui.py
+++ b/src/fastcs/transports/epics/gui.py
@@ -33,14 +33,12 @@
String,
Waveform,
)
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.methods import Command
from fastcs.transports.controller_api import ControllerAPI
from fastcs.transports.epics.options import EpicsGUIFormat, EpicsGUIOptions
from fastcs.util import snake_to_pascal
-logger = bind_logger(logger_name=__name__)
-
class EpicsGUI:
"""For creating gui in the EPICS transports."""
diff --git a/src/fastcs/transports/epics/pva/transport.py b/src/fastcs/transports/epics/pva/transport.py
index 1ccc8042d..14854dea7 100644
--- a/src/fastcs/transports/epics/pva/transport.py
+++ b/src/fastcs/transports/epics/pva/transport.py
@@ -1,7 +1,7 @@
import asyncio
from dataclasses import dataclass, field
-from fastcs.logging import bind_logger
+from fastcs.logging import logger
from fastcs.transports.controller_api import ControllerAPI
from fastcs.transports.epics import (
EpicsDocsOptions,
@@ -14,8 +14,6 @@
from .ioc import P4PIOC
-logger = bind_logger(logger_name=__name__)
-
@dataclass
class EpicsPVATransport(Transport):