Skip to content

Commit

Permalink
make a new log
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Oct 10, 2024
1 parent 5f61c90 commit 212e0aa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/opentrons/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ class ConfigElement(NamedTuple):
" absolute path, it will be used directly. If it is a "
"relative path it will be relative to log_dir",
),
ConfigElement(
"sensor_log_file",
"SENSOR Log File",
Path("logs") / "sensor.log",
ConfigElementType.FILE,
"The location of the file to save SENSOR logs to. If this is an"
" absolute path, it will be used directly. If it is a "
"relative path it will be relative to log_dir",
),
ConfigElement(
"serial_log_file",
"Serial Log File",
Expand Down
35 changes: 35 additions & 0 deletions api/src/opentrons/util/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
def _host_config(level_value: int) -> Dict[str, Any]:
serial_log_filename = CONFIG["serial_log_file"]
api_log_filename = CONFIG["api_log_file"]
sensor_log_filename = CONFIG["sensor_log_file"]
return {
"version": 1,
"disable_existing_loggers": False,
Expand Down Expand Up @@ -41,6 +42,14 @@ def _host_config(level_value: int) -> Dict[str, Any]:
"level": logging.DEBUG,
"backupCount": 5,
},
"sensor": {
"class": "logging.handlers.RotatingFileHandler",
"formatter": "basic",
"filename": sensor_log_filename,
"maxBytes": 1000000,
"level": logging.DEBUG,
"backupCount": 5,
},
},
"loggers": {
"opentrons": {
Expand All @@ -66,6 +75,16 @@ def _host_config(level_value: int) -> Dict[str, Any]:
"level": logging.DEBUG,
"propagate": False,
},
"opentrons_hardware.sensors.sensor_driver": {
"handlers": ["sensor"],
"level": logging.DEBUG,
"propagate": False,
},
"opentrons_hardware.hardware_control.tool_sensors": {
"handlers": ["sensor"],
"level": logging.DEBUG,
"propagate": False,
},
"__main__": {"handlers": ["api"], "level": level_value},
},
}
Expand Down Expand Up @@ -106,6 +125,12 @@ def _buildroot_config(level_value: int) -> Dict[str, Any]:
"formatter": "message_only",
"SYSLOG_IDENTIFIER": "opentrons-api-serial-usbbin",
},
"sensor": {
"class": "systemd.journal.JournalHandler",
"level": logging.DEBUG,
"formatter": "message_only",
"SYSLOG_IDENTIFIER": "opentrons-api-sensor",
},
},
"loggers": {
"opentrons.drivers.asyncio.communication.serial_connection": {
Expand All @@ -131,6 +156,16 @@ def _buildroot_config(level_value: int) -> Dict[str, Any]:
"level": logging.DEBUG,
"propagate": False,
},
"opentrons_hardware.sensors.sensor_driver": {
"handlers": ["sensor"],
"level": logging.DEBUG,
"propagate": False,
},
"opentrons_hardware.hardware_control.tool_sensors": {
"handlers": ["sensor"],
"level": logging.DEBUG,
"propagate": False,
},
"__main__": {"handlers": ["api"], "level": level_value},
},
}
Expand Down

0 comments on commit 212e0aa

Please sign in to comment.