provide-foundation 0.0.0.dev0__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.
Files changed (149) hide show
  1. provide/__init__.py +15 -0
  2. provide/foundation/__init__.py +155 -0
  3. provide/foundation/_version.py +58 -0
  4. provide/foundation/cli/__init__.py +67 -0
  5. provide/foundation/cli/commands/__init__.py +3 -0
  6. provide/foundation/cli/commands/deps.py +71 -0
  7. provide/foundation/cli/commands/logs/__init__.py +63 -0
  8. provide/foundation/cli/commands/logs/generate.py +357 -0
  9. provide/foundation/cli/commands/logs/generate_old.py +569 -0
  10. provide/foundation/cli/commands/logs/query.py +174 -0
  11. provide/foundation/cli/commands/logs/send.py +166 -0
  12. provide/foundation/cli/commands/logs/tail.py +112 -0
  13. provide/foundation/cli/decorators.py +262 -0
  14. provide/foundation/cli/main.py +65 -0
  15. provide/foundation/cli/testing.py +220 -0
  16. provide/foundation/cli/utils.py +210 -0
  17. provide/foundation/config/__init__.py +106 -0
  18. provide/foundation/config/base.py +295 -0
  19. provide/foundation/config/env.py +369 -0
  20. provide/foundation/config/loader.py +311 -0
  21. provide/foundation/config/manager.py +387 -0
  22. provide/foundation/config/schema.py +284 -0
  23. provide/foundation/config/sync.py +281 -0
  24. provide/foundation/config/types.py +78 -0
  25. provide/foundation/config/validators.py +80 -0
  26. provide/foundation/console/__init__.py +29 -0
  27. provide/foundation/console/input.py +364 -0
  28. provide/foundation/console/output.py +178 -0
  29. provide/foundation/context/__init__.py +12 -0
  30. provide/foundation/context/core.py +356 -0
  31. provide/foundation/core.py +20 -0
  32. provide/foundation/crypto/__init__.py +182 -0
  33. provide/foundation/crypto/algorithms.py +111 -0
  34. provide/foundation/crypto/certificates.py +896 -0
  35. provide/foundation/crypto/checksums.py +301 -0
  36. provide/foundation/crypto/constants.py +57 -0
  37. provide/foundation/crypto/hashing.py +265 -0
  38. provide/foundation/crypto/keys.py +188 -0
  39. provide/foundation/crypto/signatures.py +144 -0
  40. provide/foundation/crypto/utils.py +164 -0
  41. provide/foundation/errors/__init__.py +96 -0
  42. provide/foundation/errors/auth.py +73 -0
  43. provide/foundation/errors/base.py +81 -0
  44. provide/foundation/errors/config.py +103 -0
  45. provide/foundation/errors/context.py +299 -0
  46. provide/foundation/errors/decorators.py +484 -0
  47. provide/foundation/errors/handlers.py +360 -0
  48. provide/foundation/errors/integration.py +105 -0
  49. provide/foundation/errors/platform.py +37 -0
  50. provide/foundation/errors/process.py +140 -0
  51. provide/foundation/errors/resources.py +133 -0
  52. provide/foundation/errors/runtime.py +160 -0
  53. provide/foundation/errors/safe_decorators.py +133 -0
  54. provide/foundation/errors/types.py +276 -0
  55. provide/foundation/file/__init__.py +79 -0
  56. provide/foundation/file/atomic.py +157 -0
  57. provide/foundation/file/directory.py +134 -0
  58. provide/foundation/file/formats.py +236 -0
  59. provide/foundation/file/lock.py +175 -0
  60. provide/foundation/file/safe.py +179 -0
  61. provide/foundation/file/utils.py +170 -0
  62. provide/foundation/hub/__init__.py +88 -0
  63. provide/foundation/hub/click_builder.py +310 -0
  64. provide/foundation/hub/commands.py +42 -0
  65. provide/foundation/hub/components.py +640 -0
  66. provide/foundation/hub/decorators.py +244 -0
  67. provide/foundation/hub/info.py +32 -0
  68. provide/foundation/hub/manager.py +446 -0
  69. provide/foundation/hub/registry.py +279 -0
  70. provide/foundation/hub/type_mapping.py +54 -0
  71. provide/foundation/hub/types.py +28 -0
  72. provide/foundation/logger/__init__.py +41 -0
  73. provide/foundation/logger/base.py +22 -0
  74. provide/foundation/logger/config/__init__.py +16 -0
  75. provide/foundation/logger/config/base.py +40 -0
  76. provide/foundation/logger/config/logging.py +394 -0
  77. provide/foundation/logger/config/telemetry.py +188 -0
  78. provide/foundation/logger/core.py +239 -0
  79. provide/foundation/logger/custom_processors.py +172 -0
  80. provide/foundation/logger/emoji/__init__.py +44 -0
  81. provide/foundation/logger/emoji/matrix.py +209 -0
  82. provide/foundation/logger/emoji/sets.py +458 -0
  83. provide/foundation/logger/emoji/types.py +56 -0
  84. provide/foundation/logger/factories.py +56 -0
  85. provide/foundation/logger/processors/__init__.py +13 -0
  86. provide/foundation/logger/processors/main.py +254 -0
  87. provide/foundation/logger/processors/trace.py +113 -0
  88. provide/foundation/logger/ratelimit/__init__.py +31 -0
  89. provide/foundation/logger/ratelimit/limiters.py +294 -0
  90. provide/foundation/logger/ratelimit/processor.py +203 -0
  91. provide/foundation/logger/ratelimit/queue_limiter.py +305 -0
  92. provide/foundation/logger/setup/__init__.py +29 -0
  93. provide/foundation/logger/setup/coordinator.py +138 -0
  94. provide/foundation/logger/setup/emoji_resolver.py +64 -0
  95. provide/foundation/logger/setup/processors.py +85 -0
  96. provide/foundation/logger/setup/testing.py +39 -0
  97. provide/foundation/logger/trace.py +38 -0
  98. provide/foundation/metrics/__init__.py +119 -0
  99. provide/foundation/metrics/otel.py +122 -0
  100. provide/foundation/metrics/simple.py +165 -0
  101. provide/foundation/observability/__init__.py +53 -0
  102. provide/foundation/observability/openobserve/__init__.py +79 -0
  103. provide/foundation/observability/openobserve/auth.py +72 -0
  104. provide/foundation/observability/openobserve/client.py +307 -0
  105. provide/foundation/observability/openobserve/commands.py +357 -0
  106. provide/foundation/observability/openobserve/exceptions.py +41 -0
  107. provide/foundation/observability/openobserve/formatters.py +298 -0
  108. provide/foundation/observability/openobserve/models.py +134 -0
  109. provide/foundation/observability/openobserve/otlp.py +320 -0
  110. provide/foundation/observability/openobserve/search.py +222 -0
  111. provide/foundation/observability/openobserve/streaming.py +235 -0
  112. provide/foundation/platform/__init__.py +44 -0
  113. provide/foundation/platform/detection.py +193 -0
  114. provide/foundation/platform/info.py +157 -0
  115. provide/foundation/process/__init__.py +39 -0
  116. provide/foundation/process/async_runner.py +373 -0
  117. provide/foundation/process/lifecycle.py +406 -0
  118. provide/foundation/process/runner.py +390 -0
  119. provide/foundation/setup/__init__.py +101 -0
  120. provide/foundation/streams/__init__.py +44 -0
  121. provide/foundation/streams/console.py +57 -0
  122. provide/foundation/streams/core.py +65 -0
  123. provide/foundation/streams/file.py +104 -0
  124. provide/foundation/testing/__init__.py +166 -0
  125. provide/foundation/testing/cli.py +227 -0
  126. provide/foundation/testing/crypto.py +163 -0
  127. provide/foundation/testing/fixtures.py +49 -0
  128. provide/foundation/testing/hub.py +23 -0
  129. provide/foundation/testing/logger.py +106 -0
  130. provide/foundation/testing/streams.py +54 -0
  131. provide/foundation/tracer/__init__.py +49 -0
  132. provide/foundation/tracer/context.py +115 -0
  133. provide/foundation/tracer/otel.py +135 -0
  134. provide/foundation/tracer/spans.py +174 -0
  135. provide/foundation/types.py +32 -0
  136. provide/foundation/utils/__init__.py +97 -0
  137. provide/foundation/utils/deps.py +195 -0
  138. provide/foundation/utils/env.py +491 -0
  139. provide/foundation/utils/formatting.py +483 -0
  140. provide/foundation/utils/parsing.py +235 -0
  141. provide/foundation/utils/rate_limiting.py +112 -0
  142. provide/foundation/utils/streams.py +67 -0
  143. provide/foundation/utils/timing.py +93 -0
  144. provide_foundation-0.0.0.dev0.dist-info/METADATA +469 -0
  145. provide_foundation-0.0.0.dev0.dist-info/RECORD +149 -0
  146. provide_foundation-0.0.0.dev0.dist-info/WHEEL +5 -0
  147. provide_foundation-0.0.0.dev0.dist-info/entry_points.txt +2 -0
  148. provide_foundation-0.0.0.dev0.dist-info/licenses/LICENSE +201 -0
  149. provide_foundation-0.0.0.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,458 @@
1
+ # src/provide/foundation/telemetry/emoji_sets.py
2
+ """
3
+ Predefined Emoji Sets for Foundation Telemetry.
4
+
5
+ This module contains definitions for built-in emoji set configurations that provide
6
+ visual emoji mappings for common technologies and domains like LLMs, HTTP interactions,
7
+ and databases.
8
+ """
9
+
10
+ from provide.foundation.logger.emoji.matrix import (
11
+ PRIMARY_EMOJI,
12
+ SECONDARY_EMOJI,
13
+ TERTIARY_EMOJI,
14
+ )
15
+ from provide.foundation.logger.emoji.types import (
16
+ EmojiSet,
17
+ EmojiSetConfig,
18
+ FieldToEmojiMapping,
19
+ )
20
+
21
+ # --- Core DAS Layer Definition (Internal representation) ---
22
+ # This serves as the default Domain-Action-Status system when no custom layers are active.
23
+ # It handles the standard keys "domain", "action", "status".
24
+ LEGACY_DAS_EMOJI_SETS: list[EmojiSet] = [
25
+ EmojiSet(name="_legacy_domain", emojis=PRIMARY_EMOJI, default_emoji_key="default"),
26
+ EmojiSet(
27
+ name="_legacy_action", emojis=SECONDARY_EMOJI, default_emoji_key="default"
28
+ ),
29
+ EmojiSet(name="_legacy_status", emojis=TERTIARY_EMOJI, default_emoji_key="default"),
30
+ ]
31
+ LEGACY_DAS_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
32
+ FieldToEmojiMapping(log_key="domain", emoji_set_name="_legacy_domain"),
33
+ FieldToEmojiMapping(log_key="action", emoji_set_name="_legacy_action"),
34
+ FieldToEmojiMapping(log_key="status", emoji_set_name="_legacy_status"),
35
+ ]
36
+ # Note: The core DAS system is not a formal "EmojiSetConfig" that users enable by name.
37
+ # It's the default behavior used in the `add_das_emoji_prefix` processor.
38
+
39
+ # --- LLM Layer ---
40
+ LLM_EMOJI_SETS: list[EmojiSet] = [
41
+ EmojiSet(
42
+ name="llm_provider",
43
+ emojis={
44
+ "openai": "🤖",
45
+ "anthropic": "📚",
46
+ "google": "🇬",
47
+ "meta": "🦙",
48
+ "mistral": "🌬️",
49
+ "perplexity": "❓",
50
+ "cohere": "🔊",
51
+ "default": "💡",
52
+ },
53
+ default_emoji_key="default",
54
+ ),
55
+ EmojiSet(
56
+ name="llm_task",
57
+ emojis={
58
+ "generation": "✍️",
59
+ "completion": "✅",
60
+ "embedding": "🔗",
61
+ "chat": "💬",
62
+ "tool_use": "🛠️",
63
+ "summarization": "📜",
64
+ "translation": "🌐",
65
+ "classification": "🏷️",
66
+ "default": "⚡",
67
+ },
68
+ default_emoji_key="default",
69
+ ),
70
+ EmojiSet(
71
+ name="llm_outcome",
72
+ emojis={
73
+ "success": "👍",
74
+ "error": "🔥",
75
+ "filtered_input": "🛡️👁️",
76
+ "filtered_output": "🛡️🗣️",
77
+ "rate_limit": "⏳",
78
+ "partial_success": "🤏",
79
+ "tool_call": "📞",
80
+ "default": "➡️",
81
+ },
82
+ default_emoji_key="default",
83
+ ),
84
+ ]
85
+ LLM_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
86
+ FieldToEmojiMapping(
87
+ log_key="llm.provider",
88
+ description="Name of the LLM provider (e.g., openai, anthropic)",
89
+ value_type="string",
90
+ emoji_set_name="llm_provider",
91
+ ),
92
+ FieldToEmojiMapping(
93
+ log_key="llm.task",
94
+ description="The specific LLM task being performed (e.g., generation, chat)",
95
+ value_type="string",
96
+ emoji_set_name="llm_task",
97
+ ),
98
+ FieldToEmojiMapping(
99
+ log_key="llm.model",
100
+ description="Identifier of the LLM model used",
101
+ value_type="string",
102
+ emoji_set_name="llm_provider",
103
+ ), # Reuses provider emojis for model by default
104
+ FieldToEmojiMapping(
105
+ log_key="llm.outcome",
106
+ description="Outcome of the LLM operation",
107
+ value_type="string",
108
+ emoji_set_name="llm_outcome",
109
+ ),
110
+ FieldToEmojiMapping(
111
+ log_key="llm.input.tokens",
112
+ description="Number of input tokens",
113
+ value_type="integer",
114
+ ),
115
+ FieldToEmojiMapping(
116
+ log_key="llm.output.tokens",
117
+ description="Number of output tokens",
118
+ value_type="integer",
119
+ ),
120
+ FieldToEmojiMapping(
121
+ log_key="llm.tool.name",
122
+ description="Name of the tool called by the LLM",
123
+ value_type="string",
124
+ ),
125
+ FieldToEmojiMapping(
126
+ log_key="llm.tool.call_id",
127
+ description="Identifier for a specific tool call",
128
+ value_type="string",
129
+ ),
130
+ FieldToEmojiMapping(
131
+ log_key="duration_ms",
132
+ description="Duration of the LLM operation in milliseconds",
133
+ value_type="integer",
134
+ ),
135
+ FieldToEmojiMapping(
136
+ log_key="trace_id",
137
+ description="Distributed trace ID for the operation",
138
+ value_type="string",
139
+ ),
140
+ ]
141
+ LLM_EMOJI_SET = EmojiSetConfig(
142
+ name="llm",
143
+ description="Emoji mappings for logging Large Language Model interactions.",
144
+ emoji_sets=LLM_EMOJI_SETS,
145
+ field_definitions=LLM_FIELD_DEFINITIONS,
146
+ priority=100, # High priority
147
+ )
148
+
149
+ # --- Database Layer ---
150
+ DB_EMOJI_SETS: list[EmojiSet] = [
151
+ EmojiSet(
152
+ name="db_system",
153
+ emojis={
154
+ "postgres": "🐘",
155
+ "mysql": "🐬",
156
+ "sqlite": "💾",
157
+ "mongodb": "🍃",
158
+ "redis": "🟥",
159
+ "elasticsearch": "🔍",
160
+ "default": "🗄️",
161
+ },
162
+ default_emoji_key="default",
163
+ ),
164
+ EmojiSet(
165
+ name="db_operation",
166
+ emojis={
167
+ "query": "🔍",
168
+ "select": "🔍",
169
+ "insert": "➕",
170
+ "update": "🔄",
171
+ "delete": "🗑️",
172
+ "connect": "🔗",
173
+ "disconnect": "💔",
174
+ "transaction_begin": "💳🟢",
175
+ "transaction_commit": "💳✅",
176
+ "transaction_rollback": "💳❌",
177
+ "default": "⚙️",
178
+ },
179
+ default_emoji_key="default",
180
+ ),
181
+ EmojiSet( # Can reuse llm_outcome or define specific DB outcomes
182
+ name="db_outcome",
183
+ emojis={
184
+ "success": "👍",
185
+ "error": "🔥",
186
+ "not_found": "❓🤷",
187
+ "timeout": "⏱️",
188
+ "default": "➡️",
189
+ },
190
+ default_emoji_key="default",
191
+ ),
192
+ ]
193
+ DB_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
194
+ FieldToEmojiMapping(
195
+ log_key="db.system",
196
+ description="Type of database system (e.g., postgres, mysql)",
197
+ value_type="string",
198
+ emoji_set_name="db_system",
199
+ ),
200
+ FieldToEmojiMapping(
201
+ log_key="db.operation",
202
+ description="Database operation performed (e.g., query, insert)",
203
+ value_type="string",
204
+ emoji_set_name="db_operation",
205
+ ),
206
+ FieldToEmojiMapping(
207
+ log_key="db.statement",
208
+ description="The database statement executed (potentially truncated/sanitized)",
209
+ value_type="string",
210
+ ),
211
+ FieldToEmojiMapping(
212
+ log_key="db.table",
213
+ description="Name of the database table involved",
214
+ value_type="string",
215
+ emoji_set_name="db_system",
216
+ default_emoji_override_key="default",
217
+ ), # Use default DB emoji
218
+ FieldToEmojiMapping(
219
+ log_key="db.rows_affected",
220
+ description="Number of rows affected by the operation",
221
+ value_type="integer",
222
+ ),
223
+ FieldToEmojiMapping(
224
+ log_key="db.outcome",
225
+ description="Outcome of the database operation",
226
+ value_type="string",
227
+ emoji_set_name="db_outcome",
228
+ ),
229
+ FieldToEmojiMapping(
230
+ log_key="duration_ms",
231
+ description="Duration of the database operation in milliseconds",
232
+ value_type="integer",
233
+ ),
234
+ FieldToEmojiMapping(
235
+ log_key="trace_id",
236
+ description="Distributed trace ID for the operation",
237
+ value_type="string",
238
+ ),
239
+ ]
240
+ DATABASE_EMOJI_SET = EmojiSetConfig(
241
+ name="database",
242
+ description="Emoji mappings for logging database interactions.",
243
+ emoji_sets=DB_EMOJI_SETS,
244
+ field_definitions=DB_FIELD_DEFINITIONS,
245
+ priority=90,
246
+ )
247
+
248
+ # --- HTTP Layer (Client/Server) ---
249
+ HTTP_EMOJI_SETS: list[EmojiSet] = [
250
+ EmojiSet(
251
+ name="http_method",
252
+ emojis={
253
+ "get": "📥",
254
+ "post": "📤",
255
+ "put": "📝⬆️",
256
+ "delete": "🗑️",
257
+ "patch": "🩹",
258
+ "head": "👤❔",
259
+ "options": "⚙️❔",
260
+ "default": "🌐",
261
+ },
262
+ default_emoji_key="default",
263
+ ),
264
+ EmojiSet(
265
+ name="http_status_class", # For 2xx, 3xx etc.
266
+ emojis={
267
+ "1xx": "ℹ️",
268
+ "2xx": "✅",
269
+ "3xx": "↪️",
270
+ "4xx": "⚠️CLIENT",
271
+ "5xx": "🔥SERVER",
272
+ "default": "❓",
273
+ },
274
+ default_emoji_key="default",
275
+ ),
276
+ EmojiSet(
277
+ name="http_target_type", # For path, query, fragment
278
+ emojis={"path": "🛣️", "query": "❓", "fragment": "#️⃣", "default": "🎯"},
279
+ default_emoji_key="default",
280
+ ),
281
+ ]
282
+ HTTP_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
283
+ FieldToEmojiMapping(
284
+ log_key="http.method",
285
+ description="HTTP request method (e.g., GET, POST)",
286
+ value_type="string",
287
+ emoji_set_name="http_method",
288
+ ),
289
+ FieldToEmojiMapping(
290
+ log_key="http.url",
291
+ description="Full HTTP URL of the request",
292
+ value_type="string",
293
+ ),
294
+ FieldToEmojiMapping(
295
+ log_key="http.target",
296
+ description="Request target (path and query string)",
297
+ value_type="string",
298
+ emoji_set_name="http_target_type",
299
+ default_emoji_override_key="path",
300
+ ),
301
+ FieldToEmojiMapping(
302
+ log_key="http.scheme",
303
+ description="URL scheme (e.g., http, https)",
304
+ value_type="string",
305
+ ),
306
+ FieldToEmojiMapping(
307
+ log_key="http.host", description="Hostname of the request", value_type="string"
308
+ ),
309
+ FieldToEmojiMapping(
310
+ log_key="http.status_code",
311
+ description="HTTP response status code",
312
+ value_type="integer",
313
+ ),
314
+ FieldToEmojiMapping(
315
+ log_key="http.status_class",
316
+ description="HTTP status code class (e.g., 2xx, 4xx)",
317
+ value_type="string",
318
+ emoji_set_name="http_status_class",
319
+ ),
320
+ FieldToEmojiMapping(
321
+ log_key="http.request.body.size",
322
+ description="Size of HTTP request body in bytes",
323
+ value_type="integer",
324
+ ),
325
+ FieldToEmojiMapping(
326
+ log_key="http.response.body.size",
327
+ description="Size of HTTP response body in bytes",
328
+ value_type="integer",
329
+ ),
330
+ FieldToEmojiMapping(
331
+ log_key="client.address", description="Client IP address", value_type="string"
332
+ ),
333
+ FieldToEmojiMapping(
334
+ log_key="server.address",
335
+ description="Server IP address or hostname",
336
+ value_type="string",
337
+ ),
338
+ FieldToEmojiMapping(
339
+ log_key="duration_ms",
340
+ description="Duration of the HTTP request/response cycle in milliseconds",
341
+ value_type="integer",
342
+ ),
343
+ FieldToEmojiMapping(
344
+ log_key="trace_id",
345
+ description="Distributed trace ID for the operation",
346
+ value_type="string",
347
+ ),
348
+ FieldToEmojiMapping(
349
+ log_key="span_id", description="Span ID for the operation", value_type="string"
350
+ ),
351
+ FieldToEmojiMapping(
352
+ log_key="error.message",
353
+ description="Error message if request failed",
354
+ value_type="string",
355
+ ),
356
+ FieldToEmojiMapping(
357
+ log_key="error.type",
358
+ description="Type of error if request failed",
359
+ value_type="string",
360
+ ),
361
+ ]
362
+ HTTP_EMOJI_SET = EmojiSetConfig(
363
+ name="http",
364
+ description="Emoji mappings for logging HTTP client and server interactions.",
365
+ emoji_sets=HTTP_EMOJI_SETS,
366
+ field_definitions=HTTP_FIELD_DEFINITIONS,
367
+ priority=80,
368
+ )
369
+
370
+ # --- Task Queue Layer ---
371
+ TASK_QUEUE_EMOJI_SETS: list[EmojiSet] = [
372
+ EmojiSet(
373
+ name="task_system",
374
+ emojis={
375
+ "celery": "🥕",
376
+ "rq": "🟥🇶",
377
+ "dramatiq": "🎭",
378
+ "kafka": "🌊",
379
+ "rabbitmq": "🐇",
380
+ "default": "📨",
381
+ },
382
+ default_emoji_key="default",
383
+ ),
384
+ EmojiSet(
385
+ name="task_status",
386
+ emojis={
387
+ "submitted": "➡️📨",
388
+ "received": "📥",
389
+ "started": "▶️",
390
+ "progress": "🔄",
391
+ "retrying": "🔁",
392
+ "success": "✅🏁",
393
+ "failure": "❌🔥",
394
+ "revoked": "🚫",
395
+ "default": "❓",
396
+ },
397
+ default_emoji_key="default",
398
+ ),
399
+ ]
400
+ TASK_QUEUE_FIELD_DEFINITIONS: list[FieldToEmojiMapping] = [
401
+ FieldToEmojiMapping(
402
+ log_key="task.system",
403
+ description="Task queue system used (e.g., celery, rq)",
404
+ value_type="string",
405
+ emoji_set_name="task_system",
406
+ ),
407
+ FieldToEmojiMapping(
408
+ log_key="task.id",
409
+ description="Unique identifier for the task instance",
410
+ value_type="string",
411
+ ),
412
+ FieldToEmojiMapping(
413
+ log_key="task.name", description="Name of the task or job", value_type="string"
414
+ ),
415
+ FieldToEmojiMapping(
416
+ log_key="task.queue_name",
417
+ description="Name of the queue the task was processed on",
418
+ value_type="string",
419
+ ),
420
+ FieldToEmojiMapping(
421
+ log_key="task.status",
422
+ description="Current status of the task",
423
+ value_type="string",
424
+ emoji_set_name="task_status",
425
+ ),
426
+ FieldToEmojiMapping(
427
+ log_key="task.retries",
428
+ description="Number of retries for the task",
429
+ value_type="integer",
430
+ ),
431
+ FieldToEmojiMapping(
432
+ log_key="duration_ms",
433
+ description="Execution duration of the task in milliseconds",
434
+ value_type="integer",
435
+ ),
436
+ FieldToEmojiMapping(
437
+ log_key="trace_id",
438
+ description="Distributed trace ID associated with the task",
439
+ value_type="string",
440
+ ),
441
+ ]
442
+ TASK_QUEUE_EMOJI_SET = EmojiSetConfig(
443
+ name="task_queue",
444
+ description="Emoji mappings for logging asynchronous task queue operations.",
445
+ emoji_sets=TASK_QUEUE_EMOJI_SETS,
446
+ field_definitions=TASK_QUEUE_FIELD_DEFINITIONS,
447
+ priority=70,
448
+ )
449
+
450
+
451
+ # Registry of all built-in emoji sets
452
+ BUILTIN_EMOJI_SETS: dict[str, EmojiSetConfig] = {
453
+ LLM_EMOJI_SET.name: LLM_EMOJI_SET,
454
+ DATABASE_EMOJI_SET.name: DATABASE_EMOJI_SET,
455
+ HTTP_EMOJI_SET.name: HTTP_EMOJI_SET,
456
+ TASK_QUEUE_EMOJI_SET.name: TASK_QUEUE_EMOJI_SET,
457
+ # Add more emoji sets here (e.g., FILE_IO_EMOJI_SET, RPC_EMOJI_SET)
458
+ }
@@ -0,0 +1,56 @@
1
+ """
2
+ Emoji-related type definitions for the Foundation logger.
3
+
4
+ This module contains data structures for emoji mapping configurations
5
+ used in structured logging visual enhancement.
6
+ """
7
+
8
+ from attrs import define, field
9
+
10
+
11
+ @define(frozen=True, slots=True)
12
+ class EmojiSet:
13
+ """
14
+ Emoji set for registry-based component management.
15
+
16
+ This replaces EmojiSet and is used by the new component registry system.
17
+ """
18
+
19
+ name: str = field()
20
+ emojis: dict[str, str] = field(factory=lambda: {})
21
+ default_emoji_key: str = field(default="default")
22
+
23
+
24
+ @define(frozen=True, slots=True)
25
+ class FieldToEmojiMapping:
26
+ """
27
+ Defines a single log field key and its optional emoji mapping.
28
+ """
29
+
30
+ log_key: str = field() # e.g., "http.method", "llm.request.model"
31
+ description: str | None = field(default=None)
32
+ value_type: str | None = field(
33
+ default=None
34
+ ) # e.g., "string", "integer", "iso_timestamp"
35
+ emoji_set_name: str | None = field(
36
+ default=None
37
+ ) # Optional: references an EmojiSet.name
38
+ default_emoji_override_key: str | None = field(
39
+ default=None
40
+ ) # Optional: key within the emoji_set for this field's default
41
+
42
+
43
+ @define(frozen=True, slots=True)
44
+ class EmojiSetConfig:
45
+ """
46
+ Defines an emoji set configuration with emoji mappings for specific fields.
47
+ Provides visual enhancement for structured logging in specific domains.
48
+ """
49
+
50
+ name: str = field() # e.g., "llm", "database", "http_client"
51
+ description: str | None = field(default=None)
52
+ emoji_sets: list[EmojiSet] = field(factory=lambda: [])
53
+ field_definitions: list[FieldToEmojiMapping] = field(factory=lambda: [])
54
+ priority: int = field(
55
+ default=0, converter=int
56
+ ) # Higher priority layers take precedence in case of conflicts
@@ -0,0 +1,56 @@
1
+ #
2
+ # factories.py
3
+ #
4
+ """
5
+ Logger factory functions and simple setup utilities.
6
+ """
7
+
8
+ from typing import Any
9
+
10
+ from provide.foundation.logger.core import logger
11
+
12
+
13
+ def get_logger(name: str | None = None) -> Any:
14
+ """
15
+ Get a logger instance with the given name.
16
+
17
+ This is a convenience function that uses the global FoundationLogger.
18
+
19
+ Args:
20
+ name: Logger name (e.g., __name__ from a module)
21
+
22
+ Returns:
23
+ Configured structlog logger instance
24
+ """
25
+ return logger.get_logger(name)
26
+
27
+
28
+ def setup_logging(
29
+ level: str | int = "INFO",
30
+ json_logs: bool = False,
31
+ log_file: str | None = None,
32
+ **kwargs: Any,
33
+ ) -> None:
34
+ """
35
+ Simple logging setup for basic use cases.
36
+
37
+ Args:
38
+ level: Log level (string or int)
39
+ json_logs: Whether to output logs as JSON
40
+ log_file: Optional file path to write logs
41
+ **kwargs: Additional configuration options
42
+ """
43
+ from pathlib import Path
44
+
45
+ from provide.foundation.logger.config import LoggingConfig, TelemetryConfig
46
+ from provide.foundation.setup import setup_telemetry
47
+
48
+ # Convert simple parameters to full config
49
+ logging_config = LoggingConfig(
50
+ default_level=str(level).upper(),
51
+ console_formatter="json" if json_logs else "key_value",
52
+ log_file=Path(log_file) if log_file else None,
53
+ )
54
+
55
+ telemetry_config = TelemetryConfig(logging=logging_config, **kwargs)
56
+ setup_telemetry(telemetry_config)
@@ -0,0 +1,13 @@
1
+ """Processors package for Foundation logging."""
2
+
3
+ from provide.foundation.logger.processors.main import (
4
+ _build_core_processors_list,
5
+ _build_formatter_processors_list,
6
+ )
7
+ from provide.foundation.logger.processors.trace import inject_trace_context
8
+
9
+ __all__ = [
10
+ "_build_core_processors_list",
11
+ "_build_formatter_processors_list",
12
+ "inject_trace_context",
13
+ ]