# Deoxys Logger
Have you struggled with adding print message while debugging and need
to delete them one line after another when you finish debugging?
Logging is a simple and effective tool to manage different types of
messages. In this repo, we support loggign both for python end and C++
end.
## Logger for python programs
Remember to import!
For using all the following functions, make sure you did
```shell
from deoxys.utils import log_utils
```
For the python programs, we have three loggers defined by default: ``Deoxys``, ``deoxys_examples``, ``project``. ``Deoxys`` logger records information from
the controller codebase implementation, ``deoxys_examples`` logger
records information for example scripts we provide, and ``project`` is a
default logger we defined for your own project. All three loggers are
streamed to console by default. To change this default behavior, you
can change the ``level`` in deoxys_default_logger.yml, or you can create your own
configuration file and specify it through the function [get_deoxys_logger()](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/deoxys/utils/log_utils.py#L86).
### Logger ``Deoxys``
Mainly you need to watch out for the warning and error messages from
this logger.
### Logger ``deoxys_examples``
This is mainly for giving people an example of how to do logging in
this codebase. We use this logger in the example scripts to differentiate logging messages from ``Deoxys`` logger.
### Logger ``project``
We also have a default logger setting for your own project codebase.
If you specify ``project_name`` when calling the ``get_project_logger`` function, a logger with the name of
``project_name`` will be initialized, and its configuration is the same
as the default ``project`` logger
## Logger for C++ programs
Logging in c++ part of codebase is based on ``spdlog``. Our implementation of logging in the C++ codebase is minimal. We implemented two [sinks](https://spdlog.docsforge.com/v1.x/4.sinks/), one for console and one for file logging. We use [async logger](https://spdlog.docsforge.com/v1.x/6.asynchronous-logging/) to bypass the read/write blocking of logging. The implementation can be found [here](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/franka-interface/include/utils/log_utils.h#L36).
We specify two different loggers for the arm control process and the gripper control process. All the logging configurations are specified in our example robot config file [charmander.yml](https://github.com/UT-Austin-RPL/deoxys_control/blob/main/deoxys/config/charmander.yml). You can create your own config under the name of your machine and tune the parameters.
### Logger ``arm_logger``
The logger `arm_logger` logs all the messages we consider important to show for arm control.
The logger `arm_logger` streams `info` level messages to the console. You can change the level in the config file [here](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/config/charmander.yml#L25).
The logger `arm_logger` logs all messages whose levels are above `debug` into the file logs. You can change the level in the config file [here](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/config/charmander.yml#L29).
### Logger ``gripper_logger``
The logger `gripper_logger` logs all the messages we consider important to show for gripper control.
The logger `gripper_logger` streams `info` level messages to the console. You can change the level in the config file [here](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/config/charmander.yml#L35).
The logger `gripper_logger` logs all messages whose levels are above `debug` into the file logs. You can change the level in the config file [here](https://github.com/UT-Austin-RPL/deoxys_control/blob/33d9fd446023f86a99a17f65ee81784786267396/deoxys/config/charmander.yml#L39).
Here is a quick overview of logging levels and their corresponding messages in our codebase:
| Logger level | Message contents |
|:------------------|:-------|
| error | Missing config files, franka exceptions |
| warning | No valid controller is specified in the received message |
| info (console default) | Initiailization info, gripper information |
| debug (file log default) | Control callback information |