rainbow-rb-log 0.0.9.dev5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: rainbow-rb-log
3
+ Version: 0.0.9.dev5
4
+ Summary: Rainbow Log
5
+ Author-email: Derek <dfd1123@rainbow-robotics.com>
6
+ Requires-Python: <3.13,>=3.12
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: rainbow-rb-zenoh==0.0.9.dev5
9
+ Requires-Dist: rainbow-rb-flat-buffers==0.0.9.dev5
10
+
11
+ # rb_log
@@ -0,0 +1 @@
1
+ # rb_log
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rainbow-rb-log"
7
+ version = "0.0.9.dev5"
8
+ requires-python = ">=3.12,<3.13"
9
+ description = "Rainbow Log"
10
+ authors = [
11
+ { name = "Derek", email = "dfd1123@rainbow-robotics.com" },
12
+ ]
13
+ readme = "README.md"
14
+
15
+ dependencies = [
16
+ "rainbow-rb-zenoh==0.0.9.dev5",
17
+ "rainbow-rb-flat-buffers==0.0.9.dev5",
18
+ ]
19
+
20
+ [tool.setuptools]
21
+ package-dir = {"" = "src"}
22
+ include-package-data = true
23
+
24
+ [tool.setuptools.packages.find]
25
+ where = ["src"]
26
+ include = ["rainbow.rb_log*"]
27
+
28
+ [tool.setuptools.package-data]
29
+ "*" = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,79 @@
1
+ from datetime import (
2
+ UTC,
3
+ datetime,
4
+ )
5
+ from zoneinfo import ZoneInfo
6
+
7
+ from rainbow.rb_flat_buffers.muscat.Muscat_Log import (
8
+ Muscat_LogT,
9
+ )
10
+ from rainbow.rb_flat_buffers.muscat.Muscat_Log_Level import Muscat_Log_Level
11
+ from rainbow.rb_zenoh.client import (
12
+ ZenohClient,
13
+ )
14
+
15
+ zenoh_client = ZenohClient()
16
+
17
+
18
+ class RBLog:
19
+ def __init__(self):
20
+ self._log_colors = {
21
+ "INFO": "\033[92m",
22
+ "WARNING": "\033[93m",
23
+ "ERROR": "\033[91m",
24
+ "USER": "\033[95m",
25
+ "DEBUG": "\033[94m",
26
+ "GENERAL": "\033[90m",
27
+ "RESET": "\033[0m",
28
+ }
29
+
30
+ self._log_numbers = {
31
+ "INFO": 0,
32
+ "WARNING": 1,
33
+ "ERROR": 2,
34
+ "USER": 3,
35
+ "DEBUG": 4,
36
+ "GENERAL": 5,
37
+ }
38
+
39
+ def info(self, message: str, disable_db: bool = False):
40
+ self._print(message, "INFO")
41
+ self._publish_zenoh(message, Muscat_Log_Level.INFO, disable_db=disable_db)
42
+
43
+ def warning(self, message: str, *, disable_db: bool = False):
44
+ self._print(message, "WARNING")
45
+ self._publish_zenoh(message, Muscat_Log_Level.WARNING, disable_db=disable_db)
46
+
47
+ def error(self, message: str, *, disable_db: bool = False):
48
+ self._print(message, "ERROR")
49
+ self._publish_zenoh(message, Muscat_Log_Level.ERROR, disable_db=disable_db)
50
+
51
+ def user(self, message: str, *, disable_db: bool = False):
52
+ self._print(message, "USER")
53
+ self._publish_zenoh(message, Muscat_Log_Level.USER, disable_db=disable_db)
54
+
55
+ def debug(self, message: str, *, disable_db: bool = True):
56
+ self._print(message, "DEBUG")
57
+ self._publish_zenoh(message, Muscat_Log_Level.DEBUG, disable_db=disable_db)
58
+
59
+ def general(self, message: str, *, disable_db: bool = False):
60
+ self._print(message, "GENERAL")
61
+ self._publish_zenoh(message, Muscat_Log_Level.GENERAL, disable_db=disable_db)
62
+
63
+ def _print(self, message: str, level: str):
64
+ print(
65
+ f"{self._log_colors[level]}[{level}][{datetime.now(ZoneInfo('Asia/Seoul')).strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]}] {message}{self._log_colors['RESET']}", flush=True
66
+ )
67
+
68
+ def _publish_zenoh(self, message: str, level: Muscat_Log_Level, *, disable_db: bool = False):
69
+ req = Muscat_LogT()
70
+ req.robotModel = "Muscat"
71
+ req.level = level
72
+ req.contents = message
73
+ req.timestamp = datetime.now(UTC).strftime("%H:%M:%S")
74
+
75
+ if not disable_db:
76
+ zenoh_client.publish("muscat/log/write", flatbuffer_req_obj=req, flatbuffer_buf_size=1024)
77
+
78
+
79
+ rb_log = RBLog()
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: rainbow-rb-log
3
+ Version: 0.0.9.dev5
4
+ Summary: Rainbow Log
5
+ Author-email: Derek <dfd1123@rainbow-robotics.com>
6
+ Requires-Python: <3.13,>=3.12
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: rainbow-rb-zenoh==0.0.9.dev5
9
+ Requires-Dist: rainbow-rb-flat-buffers==0.0.9.dev5
10
+
11
+ # rb_log
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/rainbow/rb_log/__init__.py
4
+ src/rainbow/rb_log/log.py
5
+ src/rainbow_rb_log.egg-info/PKG-INFO
6
+ src/rainbow_rb_log.egg-info/SOURCES.txt
7
+ src/rainbow_rb_log.egg-info/dependency_links.txt
8
+ src/rainbow_rb_log.egg-info/requires.txt
9
+ src/rainbow_rb_log.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ rainbow-rb-zenoh==0.0.9.dev5
2
+ rainbow-rb-flat-buffers==0.0.9.dev5