|
1 | 1 | ---
|
2 |
| -description: |
3 |
| -globs: application_sdk/**/*.py |
| 2 | +description: When asked to add or improve logs for a given module or file. |
| 3 | +globs: |
4 | 4 | alwaysApply: false
|
5 | 5 | ---
|
6 | 6 | # Logging Guidelines
|
7 | 7 |
|
8 |
| -- **Logger Configuration** |
9 |
| - - Use `AtlanLoggerAdapter` for all logging |
10 |
| - - Configure loggers using `get_logger(__name__)` |
11 |
| - - Use structured logging with context |
12 |
| - - Include request IDs in logs |
13 |
| - - Use appropriate log levels: |
14 |
| - - DEBUG: Detailed information for debugging |
15 |
| - - INFO: General operational information |
16 |
| - - WARNING: Warning messages for potential issues |
17 |
| - - ERROR: Error messages for recoverable errors |
18 |
| - - CRITICAL: Critical errors that may cause system failure |
19 |
| - - ACTIVITY: Activity-specific logging |
20 |
| - |
21 |
| -- **Log Format** |
22 |
| - ```python |
23 |
| - "<green>{time:YYYY-MM-DD HH:mm:ss}</green> <blue>[{level}]</blue> <cyan>{extra[logger_name]}</cyan> - <level>{message}</level>" |
24 |
| - ``` |
25 |
| - |
26 |
| -- **Logging Best Practices** |
27 |
| - - Include relevant context in log messages |
28 |
| - - Use structured logging for machine processing |
29 |
| - - Log exceptions with stack traces |
30 |
| - - Include request IDs in distributed systems |
31 |
| - - Use appropriate log levels |
32 |
| - - Avoid logging sensitive information |
33 |
| - - Include workflow and activity context in Temporal workflows |
34 |
| - |
35 |
| -- **Example Usage** |
36 |
| - ```python |
37 |
| - from application_sdk.observability.logger_adaptor import get_logger |
38 |
| - |
39 |
| - logger = get_logger(__name__) |
40 |
| - |
41 |
| - # Basic logging |
42 |
| - logger.info("Operation completed successfully") |
43 |
| - |
44 |
| - # Logging with context |
45 |
| - logger.info("Processing request", extra={"request_id": "123", "user": "john"}) |
46 |
| - |
47 |
| - # Error logging |
48 |
| - try: |
49 |
| - # Some operation |
50 |
| - pass |
51 |
| - except Exception as e: |
52 |
| - logger.error("Operation failed", exc_info=True) |
53 |
| - ``` |
| 8 | +This rule establishes standardized logging practices for the Application SDK using `AtlanLoggerAdapter`. |
| 9 | + |
| 10 | +## Logger Configuration |
| 11 | + |
| 12 | +- Always configure loggers using the `get_logger(__name__)` function in `application_sdk.observability.logger_adaptor.py` for all logging needs. |
| 13 | + - This creates a `AtlanLoggerAdapter` singleton instance that can used multiple times. |
| 14 | +- Use structured logging with context |
| 15 | +- Include request IDs in logs |
| 16 | +- Use appropriate log levels: |
| 17 | + - DEBUG: Detailed information for debugging |
| 18 | + - INFO: General operational information |
| 19 | + - WARNING: Warning messages for potential issues |
| 20 | + - ERROR: Error messages for recoverable errors |
| 21 | + - CRITICAL: Critical errors that may cause system failure |
| 22 | + - ACTIVITY: Activity-specific logging |
| 23 | + |
| 24 | +## Logging Best Practices |
| 25 | + |
| 26 | +- Include relevant context in log messages |
| 27 | +- Use structured logging for machine processing |
| 28 | +- Log exceptions with stack traces |
| 29 | +- Include request IDs in distributed systems |
| 30 | +- Use appropriate log levels |
| 31 | +- Avoid logging sensitive information |
| 32 | +- Include workflow and activity context in Temporal workflows |
| 33 | + |
| 34 | +## Example Usage |
| 35 | + |
| 36 | +```python |
| 37 | +from application_sdk.observability.logger_adaptor import get_logger |
| 38 | + |
| 39 | +logger = get_logger(__name__) |
| 40 | + |
| 41 | +# Basic logging |
| 42 | +logger.info("Operation completed successfully") |
| 43 | + |
| 44 | +# Logging with context |
| 45 | +logger.info("Processing request", extra={"request_id": "123", "user": "john"}) |
| 46 | + |
| 47 | +# Error logging |
| 48 | +try: |
| 49 | + # Some operation |
| 50 | + pass |
| 51 | +except Exception as e: |
| 52 | + logger.error("Operation failed", exc_info=True) |
| 53 | +``` |
0 commit comments