There is no problem if you want to register the same device twice or
even more times: it will automatically remap adding or removing links
...
...
@@ -118,12 +208,18 @@ you want to register it a child.
The Bliss barebone map is something like this:
```
beamline -> devices
-> sessions
-> comms
-> counters
```
{% dot session_map_basic.svg
strict digraph {
node [label="\N"];
session;
devices;'
session -> devices;
comms;
session -> comms;
counters;
session -> counters;
}
%}
Those Graph nodes are in fact string and they constitute the root to
wich all other nodes will be attached.
...
...
@@ -134,4 +230,50 @@ devices.
## Logging Instance Methods
TODO
Every instance that inherits from LogMixin and is registered gains a _logger instance that is in fact a python logging.Logger instance with some more powers.
This means that you will find a ._logger attribute attached to your instance that you can use to send messages and configure logging.
The most useful methods are:
* .debugon()
* .debugoff()
* .debug_data(message, data)
* .set_ascii_format()
* .set_hex_format()
### .debugon() and .debugoff()
Simply to set logging level to DEBUG or reset to default level.
The purpose of debug_data is to have a convenient way to debug aggregate data like string, bytestrings and dictionary. This is helpful for hardware comunication.
The first argument of debug_data is the user-readable message, the second is a string, bytestring or a dictionary.
set_ascii_format and set_hex_format methods allows to change the representation of data at runtime.
*`-` if the level is inherited from the upper level
more info about [Python logging module](https://docs.python.org/3/library/logging.html).
### Module logging
Module-level logging is the standard python "way of logging" in which every
*logger* has the same name as the python module producing it.
The hierarchy is given by files organization inside Bliss project folder.
```python
DEMO[2]:lslog()
...
...
@@ -53,11 +74,17 @@ bliss.standard WARNING -
...
```
Inside modules logger object are instantiated with the well known:
```python
importlogging
logger=logging.getLogger(__name__)
```
Thiss will create a logger with a name that will be a commad separated folder/file name hierarchy.
### Instance logging
Same remarks for Instance logging which is a specific Bliss logging in
which every logger has a name that represents the instance hierarchy.
Instance-level logging allows to discriminate beetween different instances of the same class. With instance logging every device or instance has his own logger with a name that represents the conceptual hierarchy of the hardware/software stack.
```
DEMO [2]: lslog()
...
...
@@ -92,8 +119,15 @@ beamline.sessions WARNING -
### Devices and instances
Probably the most convenient way to activate logging for a specific
device is from the `_logger` method of the device itself:
Activate logging can be done as following:
```
TEST_SESSION [1]: log.debugon('*s1d') # using glob pattern
NO bliss loggers found for [*s1d]
Set logger [beamline.devices.8d6318d713ee6be.axis.s1d] to DEBUG level
```
Or within the device itself:
```
BLISS [1]: m0 = config.get('m0')
...
...
@@ -125,16 +159,30 @@ Activating debug from one specific device may not give the desired
informations as a device could be managed by a controller and a
controller may handle a communication.
To collect all informations activate debug at the higher level,
usually for the controller.
Sometimes what you will probably need is to activate debug from the controller level.
```
log.debugon('8d6318d7dde')
TEST_SESSION [4]: log.debugon('*8d6318d7*')
NO bliss loggers found for [*8d6318d7*]
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.hooked_error_m0] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.hooked_m0] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.hooked_m1] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.jogger] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.m0] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.m1] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.m2] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.omega] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.roby] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.s1b] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.s1d] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.s1f] to DEBUG level
Set logger [beamline.devices.8d6318d713ee6beb9efbb5be322b8dde.axis.s1u] to DEBUG level
```
## log commands
The class container for log commands.
The class instance for log commands.
### log.lslog() or lslog()
...
...
@@ -205,11 +253,10 @@ beamline.counters DEBUG YES
### log.debugon()
`log.debugon("logger name or part of it")` activates debug for a
specific logger name, it will match also if is only a part of the