logdash 0.2.0__tar.gz → 0.2.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.
- {logdash-0.2.0/logdash.egg-info → logdash-0.2.1}/PKG-INFO +1 -1
- {logdash-0.2.0 → logdash-0.2.1}/logdash/constants.py +7 -9
- {logdash-0.2.0 → logdash-0.2.1}/logdash/logger.py +20 -7
- {logdash-0.2.0 → logdash-0.2.1/logdash.egg-info}/PKG-INFO +1 -1
- {logdash-0.2.0 → logdash-0.2.1}/setup.py +1 -1
- {logdash-0.2.0 → logdash-0.2.1}/LICENSE +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/MANIFEST.in +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/README.md +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/examples/basic_usage.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/__init__.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/core.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/internal.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/metrics/__init__.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/metrics/base.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/metrics/factory.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/metrics/impl.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/metrics/noop.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/sync/__init__.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/sync/base.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/sync/factory.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/sync/http.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash/sync/noop.py +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash.egg-info/SOURCES.txt +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash.egg-info/dependency_links.txt +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash.egg-info/requires.txt +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/logdash.egg-info/top_level.txt +0 -0
- {logdash-0.2.0 → logdash-0.2.1}/setup.cfg +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Constants used throughout the logdash SDK."""
|
|
2
2
|
|
|
3
3
|
from enum import Enum
|
|
4
|
-
from colorama import Fore
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
class LogLevel(str, Enum):
|
|
@@ -21,13 +20,12 @@ class MetricOperation(str, Enum):
|
|
|
21
20
|
CHANGE = "change"
|
|
22
21
|
|
|
23
22
|
|
|
24
|
-
# Color mapping for log levels in terminal output
|
|
25
23
|
LOG_LEVEL_COLORS = {
|
|
26
|
-
LogLevel.ERROR:
|
|
27
|
-
LogLevel.WARN:
|
|
28
|
-
LogLevel.INFO:
|
|
29
|
-
LogLevel.HTTP:
|
|
30
|
-
LogLevel.VERBOSE:
|
|
31
|
-
LogLevel.DEBUG:
|
|
32
|
-
LogLevel.SILLY:
|
|
24
|
+
LogLevel.ERROR: (231, 0, 11), # Red
|
|
25
|
+
LogLevel.WARN: (254, 154, 0), # Orange
|
|
26
|
+
LogLevel.INFO: (21, 93, 252), # Blue
|
|
27
|
+
LogLevel.HTTP: (0, 166, 166), # Teal
|
|
28
|
+
LogLevel.VERBOSE: (0, 166, 0), # Green
|
|
29
|
+
LogLevel.DEBUG: (0, 166, 62), # Light Green
|
|
30
|
+
LogLevel.SILLY: (80, 80, 80), # Gray
|
|
33
31
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"""Logger implementation for logdash."""
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
|
-
from typing import Any, Callable, Optional
|
|
5
|
-
|
|
6
|
-
from colorama import Style, init
|
|
4
|
+
from typing import Any, Callable, Optional, Tuple
|
|
7
5
|
|
|
6
|
+
from colorama import init # For Windows compatibility
|
|
8
7
|
from logdash.constants import LogLevel, LOG_LEVEL_COLORS
|
|
9
8
|
|
|
10
9
|
# Initialize colorama for cross-platform terminal colors
|
|
@@ -68,6 +67,19 @@ class Logger:
|
|
|
68
67
|
def silly(self, *data: Any) -> None:
|
|
69
68
|
"""Log a silly message (lowest priority)."""
|
|
70
69
|
self._log(LogLevel.SILLY, " ".join(str(item) for item in data))
|
|
70
|
+
|
|
71
|
+
def _rgb_to_ansi(self, rgb: Tuple[int, int, int]) -> str:
|
|
72
|
+
"""
|
|
73
|
+
Convert RGB values to ANSI color escape sequence.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
rgb: Tuple of (r, g, b) values
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
ANSI color code string
|
|
80
|
+
"""
|
|
81
|
+
r, g, b = rgb
|
|
82
|
+
return f"\033[38;2;{r};{g};{b}m"
|
|
71
83
|
|
|
72
84
|
def _log(self, level: LogLevel, message: str) -> None:
|
|
73
85
|
"""
|
|
@@ -77,14 +89,15 @@ class Logger:
|
|
|
77
89
|
level: The log level
|
|
78
90
|
message: The message to log
|
|
79
91
|
"""
|
|
80
|
-
#
|
|
81
|
-
|
|
92
|
+
# Get RGB values and convert to ANSI color
|
|
93
|
+
rgb_color = LOG_LEVEL_COLORS[level]
|
|
94
|
+
color_code = self._rgb_to_ansi(rgb_color)
|
|
82
95
|
timestamp = datetime.now().isoformat()
|
|
83
96
|
|
|
84
97
|
# Format the message with timestamp and level prefix
|
|
85
98
|
formatted_message = (
|
|
86
|
-
f"\033[
|
|
87
|
-
f"{
|
|
99
|
+
f"\033[38;2;150;150;150m[{timestamp}]\033[0m "
|
|
100
|
+
f"{color_code}{self.prefix(level)}\033[0m"
|
|
88
101
|
f"{message}"
|
|
89
102
|
)
|
|
90
103
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|