sunholo 0.128.0__tar.gz → 0.129.1__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.
Files changed (188) hide show
  1. {sunholo-0.128.0/src/sunholo.egg-info → sunholo-0.129.1}/PKG-INFO +1 -1
  2. {sunholo-0.128.0 → sunholo-0.129.1}/pyproject.toml +1 -1
  3. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/custom_logging.py +182 -26
  4. {sunholo-0.128.0 → sunholo-0.129.1/src/sunholo.egg-info}/PKG-INFO +1 -1
  5. {sunholo-0.128.0 → sunholo-0.129.1}/LICENSE.txt +0 -0
  6. {sunholo-0.128.0 → sunholo-0.129.1}/MANIFEST.in +0 -0
  7. {sunholo-0.128.0 → sunholo-0.129.1}/README.md +0 -0
  8. {sunholo-0.128.0 → sunholo-0.129.1}/setup.cfg +0 -0
  9. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/__init__.py +0 -0
  10. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/__init__.py +0 -0
  11. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/chat_history.py +0 -0
  12. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/dispatch_to_qa.py +0 -0
  13. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/fastapi/__init__.py +0 -0
  14. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/fastapi/base.py +0 -0
  15. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
  16. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/flask/__init__.py +0 -0
  17. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/flask/base.py +0 -0
  18. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/flask/qna_routes.py +0 -0
  19. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/flask/vac_routes.py +0 -0
  20. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/langserve.py +0 -0
  21. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/pubsub.py +0 -0
  22. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/route.py +0 -0
  23. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/special_commands.py +0 -0
  24. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/agents/swagger.py +0 -0
  25. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/archive/__init__.py +0 -0
  26. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/archive/archive.py +0 -0
  27. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/auth/__init__.py +0 -0
  28. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/auth/gcloud.py +0 -0
  29. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/auth/refresh.py +0 -0
  30. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/auth/run.py +0 -0
  31. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/azure/__init__.py +0 -0
  32. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/azure/auth.py +0 -0
  33. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/azure/blobs.py +0 -0
  34. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/azure/event_grid.py +0 -0
  35. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/bots/__init__.py +0 -0
  36. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/bots/discord.py +0 -0
  37. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/bots/github_webhook.py +0 -0
  38. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/bots/webapp.py +0 -0
  39. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/__init__.py +0 -0
  40. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/azure.py +0 -0
  41. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/doc_handling.py +0 -0
  42. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/encode_metadata.py +0 -0
  43. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/images.py +0 -0
  44. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/loaders.py +0 -0
  45. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/message_data.py +0 -0
  46. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/pdfs.py +0 -0
  47. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/process_chunker_data.py +0 -0
  48. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/publish.py +0 -0
  49. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/pubsub.py +0 -0
  50. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/chunker/splitter.py +0 -0
  51. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/__init__.py +0 -0
  52. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/chat_vac.py +0 -0
  53. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/cli.py +0 -0
  54. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/cli_init.py +0 -0
  55. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/configs.py +0 -0
  56. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/deploy.py +0 -0
  57. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/embedder.py +0 -0
  58. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/merge_texts.py +0 -0
  59. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/run_proxy.py +0 -0
  60. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/sun_rich.py +0 -0
  61. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/swagger.py +0 -0
  62. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/cli/vertex.py +0 -0
  63. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/components/__init__.py +0 -0
  64. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/components/llm.py +0 -0
  65. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/components/retriever.py +0 -0
  66. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/components/vectorstore.py +0 -0
  67. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/__init__.py +0 -0
  68. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/alloydb.py +0 -0
  69. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/alloydb_client.py +0 -0
  70. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/database.py +0 -0
  71. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/lancedb.py +0 -0
  72. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/create_function.sql +0 -0
  73. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
  74. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/create_table.sql +0 -0
  75. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
  76. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
  77. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/sql/sb/setup.sql +0 -0
  78. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/static_dbs.py +0 -0
  79. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/database/uuid.py +0 -0
  80. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/__init__.py +0 -0
  81. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
  82. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/cli.py +0 -0
  83. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/create_new.py +0 -0
  84. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
  85. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
  86. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/embedder/__init__.py +0 -0
  87. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/embedder/embed_chunk.py +0 -0
  88. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/embedder/embed_metadata.py +0 -0
  89. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/excel/__init__.py +0 -0
  90. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/excel/plugin.py +0 -0
  91. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/__init__.py +0 -0
  92. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/add_file.py +0 -0
  93. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/download_folder.py +0 -0
  94. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/download_url.py +0 -0
  95. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/extract_and_sign.py +0 -0
  96. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/gcs/metadata.py +0 -0
  97. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/__init__.py +0 -0
  98. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/file_handling.py +0 -0
  99. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/genaiv2.py +0 -0
  100. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/images.py +0 -0
  101. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/init.py +0 -0
  102. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/process_funcs_cls.py +0 -0
  103. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/genai/safety.py +0 -0
  104. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/invoke/__init__.py +0 -0
  105. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/invoke/async_class.py +0 -0
  106. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/invoke/direct_vac_func.py +0 -0
  107. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
  108. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/langchain_types.py +0 -0
  109. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/langfuse/__init__.py +0 -0
  110. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/langfuse/callback.py +0 -0
  111. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/langfuse/evals.py +0 -0
  112. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/langfuse/prompts.py +0 -0
  113. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/llamaindex/__init__.py +0 -0
  114. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/llamaindex/get_files.py +0 -0
  115. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/llamaindex/import_files.py +0 -0
  116. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
  117. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/llamaindex/user_history.py +0 -0
  118. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/lookup/__init__.py +0 -0
  119. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/lookup/model_lookup.yaml +0 -0
  120. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/mcp/__init__.py +0 -0
  121. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/mcp/cli.py +0 -0
  122. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/ollama/__init__.py +0 -0
  123. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/ollama/ollama_images.py +0 -0
  124. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/pubsub/__init__.py +0 -0
  125. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/pubsub/process_pubsub.py +0 -0
  126. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/pubsub/pubsub_manager.py +0 -0
  127. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/qna/__init__.py +0 -0
  128. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/qna/parsers.py +0 -0
  129. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/qna/retry.py +0 -0
  130. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/senses/__init__.py +0 -0
  131. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/senses/stream_voice.py +0 -0
  132. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/streaming/__init__.py +0 -0
  133. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/streaming/content_buffer.py +0 -0
  134. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/streaming/langserve.py +0 -0
  135. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/streaming/stream_lookup.py +0 -0
  136. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/streaming/streaming.py +0 -0
  137. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/summarise/__init__.py +0 -0
  138. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/summarise/summarise.py +0 -0
  139. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/__init__.py +0 -0
  140. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/agent_service.py +0 -0
  141. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/app.py +0 -0
  142. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/my_log.py +0 -0
  143. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/tools/__init__.py +0 -0
  144. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
  145. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/agent/vac_service.py +0 -0
  146. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/project/__init__.py +0 -0
  147. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/project/app.py +0 -0
  148. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/project/my_log.py +0 -0
  149. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/project/vac_service.py +0 -0
  150. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/system_services/__init__.py +0 -0
  151. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/system_services/app.py +0 -0
  152. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/templates/system_services/my_log.py +0 -0
  153. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/terraform/__init__.py +0 -0
  154. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/terraform/tfvars_editor.py +0 -0
  155. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/tools/__init__.py +0 -0
  156. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/tools/web_browser.py +0 -0
  157. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/__init__.py +0 -0
  158. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/api_key.py +0 -0
  159. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/big_context.py +0 -0
  160. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/config.py +0 -0
  161. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/config_class.py +0 -0
  162. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/config_schema.py +0 -0
  163. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/gcp.py +0 -0
  164. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/gcp_project.py +0 -0
  165. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/mime.py +0 -0
  166. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/parsers.py +0 -0
  167. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/timedelta.py +0 -0
  168. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/user_ids.py +0 -0
  169. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/utils/version.py +0 -0
  170. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/__init__.py +0 -0
  171. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/extensions_call.py +0 -0
  172. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/extensions_class.py +0 -0
  173. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/genai_functions.py +0 -0
  174. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/init.py +0 -0
  175. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/memory_tools.py +0 -0
  176. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/safety.py +0 -0
  177. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo/vertex/type_dict_to_json.py +0 -0
  178. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo.egg-info/SOURCES.txt +0 -0
  179. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo.egg-info/dependency_links.txt +0 -0
  180. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo.egg-info/entry_points.txt +0 -0
  181. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo.egg-info/requires.txt +0 -0
  182. {sunholo-0.128.0 → sunholo-0.129.1}/src/sunholo.egg-info/top_level.txt +0 -0
  183. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_async.py +0 -0
  184. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_async_genai2.py +0 -0
  185. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_chat_history.py +0 -0
  186. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_config.py +0 -0
  187. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_genai2.py +0 -0
  188. {sunholo-0.128.0 → sunholo-0.129.1}/tests/test_unstructured.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.128.0
3
+ Version: 0.129.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sunholo"
7
- version = "0.128.0"
7
+ version = "0.129.1"
8
8
  description = "Large Language Model DevOps - a package to help deploy LLMs to the Cloud."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -89,53 +89,100 @@ class GoogleCloudLogging:
89
89
  }
90
90
  return None
91
91
 
92
+ def update_trace_id(self, trace_id):
93
+ """
94
+ Updates the trace ID to be included in all logs.
95
+
96
+ Args:
97
+ trace_id (str): The trace ID to add to all logs.
98
+ """
99
+ self.trace_id = trace_id
100
+
101
+ def _append_trace_id(self, log_text):
102
+ """
103
+ Appends trace ID to log text if available.
104
+
105
+ Args:
106
+ log_text (str): The log message.
107
+
108
+ Returns:
109
+ str: Log message with trace ID prefixed if available.
110
+ """
111
+ if hasattr(self, 'trace_id') and self.trace_id:
112
+ return f"{self.logger_name}-{self.trace_id} {log_text}"
113
+ return log_text
114
+
115
+ def _add_trace_to_struct(self, log_struct):
116
+ """
117
+ Adds trace ID to structured log data if available.
118
+
119
+ Args:
120
+ log_struct (dict): The structured log data.
121
+
122
+ Returns:
123
+ dict: Log structure with trace ID added if available.
124
+ """
125
+ if not isinstance(log_struct, dict):
126
+ return log_struct
127
+
128
+ if hasattr(self, 'trace_id') and self.trace_id:
129
+ return {**log_struct, "trace_id": self.trace_id}
130
+ return log_struct
131
+
92
132
  def structured_log(self, log_text=None, log_struct=None, logger_name=None, severity="INFO"):
93
133
  """
94
134
  Writes log entries to the specified logger as either text or structured data.
95
-
135
+
96
136
  Args:
97
137
  log_text (str, optional): The log message as a text string. Defaults to None.
98
138
  log_struct (dict, optional): The log message as a dictionary for structured log. Defaults to None.
99
- logger_name (str, optional): The name of the logger to which to write the log entries. e.g.
100
- logName="run.googleapis.com%2Fstderr"
139
+ logger_name (str, optional): The name of the logger to which to write the log entries.
140
+ e.g. logName="run.googleapis.com%2Fstderr"
101
141
  severity (str, optional): The severity level of the log entry. Defaults to "INFO".
102
142
  """
103
-
104
143
  from .utils.version import sunholo_version
105
-
106
- log_text = f"[{sunholo_version()}] {log_text}"
107
-
144
+
145
+ if log_text is not None:
146
+ log_text = f"[{sunholo_version()}] {log_text}"
147
+ # Apply trace ID to log text
148
+ log_text = self._append_trace_id(log_text)
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)
153
+
108
154
  if not logger_name and not self.logger_name:
109
155
  raise ValueError("Must provide a logger name e.g. 'run.googleapis.com%2Fstderr'")
110
156
 
111
157
  from .utils.gcp import is_running_on_gcp, is_gcp_logged_in
112
158
  if not is_running_on_gcp() and not is_gcp_logged_in():
159
+ import logging as log
113
160
  log.basicConfig(level=log.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
114
161
  if log_text:
115
162
  log.info(f"[{severity}][{logger_name or self.logger_name}][{self.version}] - {log_text}")
116
163
  elif log_struct:
117
164
  log.info(f"[{severity}][{logger_name or self.logger_name}][{self.version}] - {str(log_struct)}")
118
-
165
+ return
166
+
119
167
  logger = self.client.logger(logger_name or self.logger_name)
120
-
168
+
121
169
  caller_info = self._get_caller_info()
122
-
170
+
123
171
  if log_text:
124
- if isinstance(log_struct, dict):
125
- logger.log_struct(log_struct, severity=severity, source_location=caller_info)
126
- elif isinstance(log_struct, str):
127
- logger.log_text(log_text, severity=severity, source_location=caller_info)
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)}")
177
+
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)}")
128
181
  else:
129
182
  try:
130
- turn_to_text = str(log_text)
131
- logger.log_text(turn_to_text, severity=severity, source_location=caller_info)
183
+ logger.log_struct(log_struct, severity=severity, source_location=caller_info)
132
184
  except Exception as err:
133
- print(f"Could not log this: {log_text=} - {str(err)}")
134
-
135
- elif log_struct:
136
- if not isinstance(log_struct, dict):
137
- raise ValueError("log_struct must be a dictionary.")
138
- logger.log_struct(log_struct, severity=severity, source_location=caller_info)
185
+ print(f"Could not log struct: {log_struct=} - {str(err)}")
139
186
 
140
187
  def debug(self, log_text=None, log_struct=None):
141
188
 
@@ -217,6 +264,53 @@ def setup_logging(logger_name=None, log_level=logging.INFO, project_id=None):
217
264
  # Now you can use Python's logging module as usual
218
265
  import logging
219
266
  log.info('This is an info message that will be sent to Google Cloud log.')
267
+
268
+ # Basic structured logging
269
+ log.info(log_struct={"action": "user_login", "user_id": "12345"})
270
+
271
+ # Structured logging with trace ID
272
+ log.update_trace_id("abc-123")
273
+ log.info(log_struct={"action": "process_started", "file_count": 42})
274
+ # This will include trace_id: "abc-123" in the logged structure
275
+
276
+ # Logging with both text and structure
277
+ log.info(
278
+ log_text="Processing completed successfully",
279
+ log_struct={"duration_ms": 1234, "items_processed": 100}
280
+ )
281
+
282
+ # Logging error with structured context
283
+ try:
284
+ # Some operation
285
+ process_data()
286
+ except Exception as e:
287
+ log.error(
288
+ log_text=f"Error processing data: {str(e)}",
289
+ log_struct={
290
+ "error_type": type(e).__name__,
291
+ "file_name": "example.csv",
292
+ "line_number": 42
293
+ }
294
+ )
295
+
296
+ # More complex structured logging
297
+ log.info(log_struct={
298
+ "request": {
299
+ "method": "POST",
300
+ "path": "/api/data",
301
+ "user_agent": "Mozilla/5.0...",
302
+ "ip": "192.168.1.1"
303
+ },
304
+ "response": {
305
+ "status_code": 200,
306
+ "processing_time_ms": 345,
307
+ "bytes_sent": 1024
308
+ },
309
+ "metadata": {
310
+ "version": "1.2.3",
311
+ "environment": "production"
312
+ }
313
+ })
220
314
 
221
315
  Note:
222
316
  This function requires that the 'google-cloud-logging' library is installed and
@@ -252,9 +346,22 @@ def setup_logging(logger_name=None, log_level=logging.INFO, project_id=None):
252
346
 
253
347
  return log
254
348
 
255
-
256
-
257
-
349
+ # for debugging
350
+ def safe_log_struct(log, severity, message, struct):
351
+ try:
352
+ if severity == "INFO":
353
+ log.info(log_text=message, log_struct=struct)
354
+ elif severity == "ERROR":
355
+ log.error(log_text=message, log_struct=struct)
356
+ # Add other severity levels as needed
357
+ except Exception as e:
358
+ print(f"Logging error: {e}")
359
+ print(f"Failed to log structure: {struct}")
360
+ # Fallback to simple text logging
361
+ if severity == "INFO":
362
+ log.info(f"{message} (struct logging failed)")
363
+ elif severity == "ERROR":
364
+ log.error(f"{message} (struct logging failed)")
258
365
 
259
366
  def log_folder_location(folder_name):
260
367
  # Get the current working directory
@@ -277,4 +384,53 @@ def get_logger():
277
384
  _logger = setup_logging("sunholo")
278
385
  return _logger
279
386
 
280
- log = get_logger()
387
+ log = get_logger()
388
+
389
+ """
390
+ # Basic structured logging
391
+ log.info(log_struct={"action": "user_login", "user_id": "12345"})
392
+
393
+ # Structured logging with trace ID
394
+ log.update_trace_id("abc-123")
395
+ log.info(log_struct={"action": "process_started", "file_count": 42})
396
+ # This will include trace_id: "abc-123" in the logged structure
397
+
398
+ # Logging with both text and structure
399
+ log.info(
400
+ log_text="Processing completed successfully",
401
+ log_struct={"duration_ms": 1234, "items_processed": 100}
402
+ )
403
+
404
+ # Logging error with structured context
405
+ try:
406
+ # Some operation
407
+ process_data()
408
+ except Exception as e:
409
+ log.error(
410
+ log_text=f"Error processing data: {str(e)}",
411
+ log_struct={
412
+ "error_type": type(e).__name__,
413
+ "file_name": "example.csv",
414
+ "line_number": 42
415
+ }
416
+ )
417
+
418
+ # More complex structured logging
419
+ log.info(log_struct={
420
+ "request": {
421
+ "method": "POST",
422
+ "path": "/api/data",
423
+ "user_agent": "Mozilla/5.0...",
424
+ "ip": "192.168.1.1"
425
+ },
426
+ "response": {
427
+ "status_code": 200,
428
+ "processing_time_ms": 345,
429
+ "bytes_sent": 1024
430
+ },
431
+ "metadata": {
432
+ "version": "1.2.3",
433
+ "environment": "production"
434
+ }
435
+ })
436
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.128.0
3
+ Version: 0.129.1
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
File without changes
File without changes
File without changes
File without changes
File without changes