@@ -81,22 +81,24 @@ class StructuredLogLevel(Enum):
81
81
ERROR = logging .ERROR
82
82
83
83
84
- class StructuredLogType (Enum ):
84
+ class StructuredLogCategory (Enum ):
85
85
"""
86
86
This is used to categorise the errors mainly based on the biggest impact area
87
87
This is to be used to help in self-serve understand the impact of any log entry
88
88
More enums to be added as logs are updated to be self-serve
89
89
"""
90
90
91
91
LINEAGE = "LINEAGE"
92
+ USAGE = "USAGE"
93
+ PROFILING = "PROFILING"
92
94
93
95
94
96
@dataclass
95
97
class StructuredLogEntry (Report ):
96
98
title : Optional [str ]
97
99
message : str
98
100
context : LossyList [str ]
99
- log_type : Optional [StructuredLogType ] = None
101
+ log_category : Optional [StructuredLogCategory ] = None
100
102
101
103
102
104
@dataclass
@@ -119,7 +121,7 @@ def report_log(
119
121
exc : Optional [BaseException ] = None ,
120
122
log : bool = False ,
121
123
stacklevel : int = 1 ,
122
- log_type : Optional [StructuredLogType ] = None ,
124
+ log_category : Optional [StructuredLogCategory ] = None ,
123
125
) -> None :
124
126
"""
125
127
Report a user-facing log for the ingestion run.
@@ -130,7 +132,7 @@ def report_log(
130
132
title: The category / heading to present on for this message in the UI.
131
133
context: Additional context (e.g. where, how) for the log entry.
132
134
exc: The exception associated with the event. We'll show the stack trace when in debug mode.
133
- log_type : The type of the log entry. This is used to categorise the log entry.
135
+ log_category : The type of the log entry. This is used to categorise the log entry.
134
136
log: Whether to log the entry to the console.
135
137
stacklevel: The stack level to use for the log entry.
136
138
"""
@@ -175,7 +177,7 @@ def report_log(
175
177
title = title ,
176
178
message = message ,
177
179
context = context_list ,
178
- log_type = log_type ,
180
+ log_category = log_category ,
179
181
)
180
182
else :
181
183
if context is not None :
@@ -235,7 +237,7 @@ def report_warning(
235
237
context : Optional [str ] = None ,
236
238
title : Optional [LiteralString ] = None ,
237
239
exc : Optional [BaseException ] = None ,
238
- log_type : Optional [StructuredLogType ] = None ,
240
+ log_category : Optional [StructuredLogCategory ] = None ,
239
241
) -> None :
240
242
"""
241
243
See docs of StructuredLogs.report_log for details of args
@@ -247,7 +249,7 @@ def report_warning(
247
249
context ,
248
250
exc ,
249
251
log = False ,
250
- log_type = log_type ,
252
+ log_category = log_category ,
251
253
)
252
254
253
255
def warning (
@@ -257,7 +259,7 @@ def warning(
257
259
title : Optional [LiteralString ] = None ,
258
260
exc : Optional [BaseException ] = None ,
259
261
log : bool = True ,
260
- log_type : Optional [StructuredLogType ] = None ,
262
+ log_category : Optional [StructuredLogCategory ] = None ,
261
263
) -> None :
262
264
"""
263
265
See docs of StructuredLogs.report_log for details of args
@@ -269,7 +271,7 @@ def warning(
269
271
context ,
270
272
exc ,
271
273
log = log ,
272
- log_type = log_type ,
274
+ log_category = log_category ,
273
275
)
274
276
275
277
def report_failure (
@@ -279,7 +281,7 @@ def report_failure(
279
281
title : Optional [LiteralString ] = None ,
280
282
exc : Optional [BaseException ] = None ,
281
283
log : bool = True ,
282
- log_type : Optional [StructuredLogType ] = None ,
284
+ log_category : Optional [StructuredLogCategory ] = None ,
283
285
) -> None :
284
286
"""
285
287
See docs of StructuredLogs.report_log for details of args
@@ -291,7 +293,7 @@ def report_failure(
291
293
context ,
292
294
exc ,
293
295
log = log ,
294
- log_type = log_type ,
296
+ log_category = log_category ,
295
297
)
296
298
297
299
def failure (
@@ -301,7 +303,7 @@ def failure(
301
303
title : Optional [LiteralString ] = None ,
302
304
exc : Optional [BaseException ] = None ,
303
305
log : bool = True ,
304
- log_type : Optional [StructuredLogType ] = None ,
306
+ log_category : Optional [StructuredLogCategory ] = None ,
305
307
) -> None :
306
308
"""
307
309
See docs of StructuredLogs.report_log for details of args
@@ -313,7 +315,7 @@ def failure(
313
315
context ,
314
316
exc ,
315
317
log = log ,
316
- log_type = log_type ,
318
+ log_category = log_category ,
317
319
)
318
320
319
321
def info (
@@ -323,7 +325,7 @@ def info(
323
325
title : Optional [LiteralString ] = None ,
324
326
exc : Optional [BaseException ] = None ,
325
327
log : bool = True ,
326
- log_type : Optional [StructuredLogType ] = None ,
328
+ log_category : Optional [StructuredLogCategory ] = None ,
327
329
) -> None :
328
330
"""
329
331
See docs of StructuredLogs.report_log for details of args
@@ -335,7 +337,7 @@ def info(
335
337
context ,
336
338
exc ,
337
339
log = log ,
338
- log_type = log_type ,
340
+ log_category = log_category ,
339
341
)
340
342
341
343
@contextlib .contextmanager
@@ -345,7 +347,7 @@ def report_exc(
345
347
title : Optional [LiteralString ] = None ,
346
348
context : Optional [str ] = None ,
347
349
level : StructuredLogLevel = StructuredLogLevel .ERROR ,
348
- log_type : Optional [StructuredLogType ] = None ,
350
+ log_category : Optional [StructuredLogCategory ] = None ,
349
351
) -> Iterator [None ]:
350
352
# Convenience method that helps avoid boilerplate try/except blocks.
351
353
# TODO: I'm not super happy with the naming here - it's not obvious that this
@@ -359,7 +361,7 @@ def report_exc(
359
361
title = title ,
360
362
context = context ,
361
363
exc = exc ,
362
- log_type = log_type ,
364
+ log_category = log_category ,
363
365
)
364
366
365
367
def __post_init__ (self ) -> None :
0 commit comments