sunholo 0.129.1__py3-none-any.whl → 0.129.2__py3-none-any.whl

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.
sunholo/custom_logging.py CHANGED
@@ -142,14 +142,25 @@ class GoogleCloudLogging:
142
142
  """
143
143
  from .utils.version import sunholo_version
144
144
 
145
+ # Add version to log_text if it exists
145
146
  if log_text is not None:
146
147
  log_text = f"[{sunholo_version()}] {log_text}"
147
- # Apply trace ID to log text
148
148
  log_text = self._append_trace_id(log_text)
149
149
 
150
- if log_struct is not None:
151
- # Add trace ID to structured log
152
- log_struct = self._add_trace_to_struct(log_struct)
150
+ # Always create or update log_struct with trace_id if available
151
+ if not log_struct:
152
+ log_struct = {}
153
+
154
+ # Make sure log_struct is a dictionary
155
+ if not isinstance(log_struct, dict):
156
+ log_struct = {"original_non_dict_value": str(log_struct)}
157
+
158
+ # Add trace ID to log_struct
159
+ if hasattr(self, 'trace_id') and self.trace_id:
160
+ log_struct["trace_id"] = self.trace_id
161
+
162
+ # Add version to log_struct
163
+ log_struct["version"] = sunholo_version()
153
164
 
154
165
  if not logger_name and not self.logger_name:
155
166
  raise ValueError("Must provide a logger name e.g. 'run.googleapis.com%2Fstderr'")
@@ -159,30 +170,28 @@ class GoogleCloudLogging:
159
170
  import logging as log
160
171
  log.basicConfig(level=log.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
161
172
  if log_text:
162
- log.info(f"[{severity}][{logger_name or self.logger_name}][{self.version}] - {log_text}")
163
- elif log_struct:
173
+ log.info(f"[{severity}][{logger_name or self.logger_name}][{self.version}] - {log_text} - {log_struct}")
174
+ else:
164
175
  log.info(f"[{severity}][{logger_name or self.logger_name}][{self.version}] - {str(log_struct)}")
165
176
  return
166
177
 
167
178
  logger = self.client.logger(logger_name or self.logger_name)
168
-
169
179
  caller_info = self._get_caller_info()
170
180
 
181
+ # Always log struct, and include message if provided
171
182
  if log_text:
172
- try:
173
- turn_to_text = str(log_text)
174
- logger.log_text(turn_to_text, severity=severity, source_location=caller_info)
175
- except Exception as err:
176
- print(f"Could not log this: {log_text=} - {str(err)}")
183
+ log_struct["message"] = log_text
177
184
 
178
- if log_struct:
179
- if not isinstance(log_struct, dict):
180
- print(f"Warning: log_struct must be a dictionary, got {type(log_struct)}")
181
- else:
182
- try:
183
- logger.log_struct(log_struct, severity=severity, source_location=caller_info)
184
- except Exception as err:
185
- print(f"Could not log struct: {log_struct=} - {str(err)}")
185
+ try:
186
+ logger.log_struct(log_struct, severity=severity, source_location=caller_info)
187
+ except Exception as err:
188
+ print(f"Failed to log struct: {err}")
189
+ # Fallback to text logging
190
+ fallback_message = log_text if log_text else str(log_struct)
191
+ try:
192
+ logger.log_text(fallback_message, severity=severity, source_location=caller_info)
193
+ except Exception as text_err:
194
+ print(f"Even fallback text logging failed: {text_err}")
186
195
 
187
196
  def debug(self, log_text=None, log_struct=None):
188
197
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.129.1
3
+ Version: 0.129.2
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -1,5 +1,5 @@
1
1
  sunholo/__init__.py,sha256=InRbX4V0-qdNHo9zYH3GEye7ASLR6LX8-SMvPV4Jsaw,1212
2
- sunholo/custom_logging.py,sha256=37oyAGc8PWqxelXX_LB298HgiwBlYfJrHyk4R4_li6o,17080
2
+ sunholo/custom_logging.py,sha256=-n7YvgqWQ8nRjCKl1bfcbeZOMTV3m-rBdZGuVyXWDR8,17433
3
3
  sunholo/langchain_types.py,sha256=uZ4zvgej_f7pLqjtu4YP7qMC_eZD5ym_5x4pyvA1Ih4,1834
4
4
  sunholo/agents/__init__.py,sha256=X2I3pPkGeKWjc3d0QgSpkTyqD8J8JtrEWqwrumf1MMc,391
5
5
  sunholo/agents/chat_history.py,sha256=Gph_CdlP2otYnNdR1q1Umyyyvcad2F6K3LxU5yBQ9l0,5387
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
168
168
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
169
169
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
170
170
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
171
- sunholo-0.129.1.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
- sunholo-0.129.1.dist-info/METADATA,sha256=1fAuA2lDi15g88z6xm0RR7vKAnhEJTCpr6nOEJ9Ly9I,10084
173
- sunholo-0.129.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
174
- sunholo-0.129.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
- sunholo-0.129.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
- sunholo-0.129.1.dist-info/RECORD,,
171
+ sunholo-0.129.2.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
+ sunholo-0.129.2.dist-info/METADATA,sha256=-G-cXG-Chu5B82pBh_4sww6YzAOkcF_6BIt1RDTJuMk,10084
173
+ sunholo-0.129.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
174
+ sunholo-0.129.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
+ sunholo-0.129.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
+ sunholo-0.129.2.dist-info/RECORD,,