API Reference¶
logxide
¶
LogXide: High-performance, Rust-powered drop-in replacement for Python's logging module.
LogXide provides a fast, async-capable logging system that maintains full compatibility with Python's standard logging module while delivering superior performance through its Rust backend.
FileHandler
¶
Filter
¶
Formatter
¶
Enhanced formatter - compatible with logging.Formatter, supports extra fields
Source code in logxide/compat_handlers.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
format(record)
¶
Format a log record using the format string.
This handles both dict records (from Rust) and LogRecord objects.
Source code in logxide/compat_handlers.py
formatException(ei)
¶
Format exception information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ei
|
Exception info tuple (type, value, traceback) |
required |
Returns:
| Type | Description |
|---|---|
|
Formatted exception string |
Source code in logxide/compat_handlers.py
formatStack(stack_info)
¶
Format stack information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack_info
|
Stack info string |
required |
Returns:
| Type | Description |
|---|---|
|
Formatted stack string |
formatTime(record, datefmt=None)
¶
Format the time for a record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
LogRecord instance |
required | |
datefmt
|
Date format string (if None, uses default format) |
None
|
Returns:
| Type | Description |
|---|---|
|
Formatted time string |
Source code in logxide/compat_handlers.py
Handler
¶
Basic handler class - compatible with logging.Handler
Note: This is a compatibility shim. LogXide uses Rust native handlers for actual log processing. Python handlers are not supported for performance reasons.
Source code in logxide/compat_handlers.py
LogRecord
¶
LoggerAdapter
¶
LoggingManager
¶
NullHandler
¶
A handler that does nothing.
Source code in logxide/__init__.py
PyLogger
¶
High-performance logger implementation.
Source code in logxide/__init__.py
SentryHandler
¶
Bases: Handler
A handler that sends log records to Sentry.
Automatically detects if Sentry SDK is available and configured. Only sends events at WARNING level and above to avoid noise.
Source code in logxide/sentry_integration.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
is_available
property
¶
Check if Sentry is available and configured.
__call__(record)
¶
__init__(level=WARNING, with_breadcrumbs=True)
¶
Initialize the Sentry handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Minimum log level to send to Sentry (default: WARNING) |
WARNING
|
with_breadcrumbs
|
bool
|
Whether to add breadcrumbs for lower-level logs |
True
|
Source code in logxide/sentry_integration.py
emit(record)
¶
Emit a log record to Sentry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
The log record to emit |
required |
Source code in logxide/sentry_integration.py
StreamHandler
¶
addLevelName(level, levelName)
¶
auto_configure_sentry(enable=None)
¶
Automatically configure Sentry integration if available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
Optional[bool]
|
Explicitly enable/disable Sentry (None for auto-detect) |
None
|
Returns:
| Type | Description |
|---|---|
Optional[SentryHandler]
|
SentryHandler instance if configured, None otherwise |
Source code in logxide/sentry_integration.py
basicConfig(**kwargs)
¶
Basic configuration for the logging system.
Supported parameters: - level: Set the effective level for the root logger - format: Format string for log messages (not implemented in Rust handlers) - datefmt: Date format string (not implemented in Rust handlers) - stream: Stream to write log output to (sys.stdout or sys.stderr supported) - filename: Log to a file instead of a stream - force: If True, remove any existing handlers and reconfigure (default: False)
Note: LogXide uses Rust native handlers for performance. All handler configuration is done through this function. Direct handler registration via addHandler() is not supported.
Like Python's standard logging, basicConfig() will do nothing if the root logger already has handlers configured, unless force=True is specified.
Source code in logxide/logger_wrapper.py
captureWarnings(capture)
¶
If capture is true, redirect all warnings to the logging package. If capture is False, ensure that warnings are not redirected to logging but to their original destinations.
This function maintains full compatibility with Python's logging.captureWarnings.
Source code in logxide/compat_functions.py
disable(level)
¶
getHandlerByName(name)
¶
Get a handler by its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the handler to retrieve |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The handler with the given name, or None if not found |
getHandlerNames()
¶
Return a list of all registered handler names.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list of handler names |
getLevelName(level)
¶
Get level name - compatibility function
Source code in logxide/compat_functions.py
getLevelNamesMapping()
¶
Return a mapping of level names to level numbers.
This function returns a copy of the internal mapping used for level name to number conversions.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, int]
|
A dictionary mapping level names to level numbers |
Source code in logxide/compat_functions.py
getLogRecordFactory()
¶
Return the factory to be used for creating log records.
Returns:
| Type | Description |
|---|---|
type[LogRecord]
|
The current log record factory function, or None if using default |
getLogger(name=None)
¶
Get a logger by name, ensuring existing loggers get LogXide functionality.
This wraps the Rust getLogger to handle cases where Python libraries created loggers before LogXide was configured.
Source code in logxide/logger_wrapper.py
getLoggerClass()
¶
Get the logger class - compatibility function
Source code in logxide/compat_functions.py
makeLogRecord(dict_)
¶
Make a LogRecord whose attributes are defined by the specified dictionary.
This function is useful for converting a logging event received over a socket connection (which is sent as a dictionary) into a LogRecord instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_
|
Dictionary containing log record attributes |
required |
Returns:
| Type | Description |
|---|---|
LogRecord
|
A LogRecord-like object (or dict for LogXide compatibility) |
Source code in logxide/compat_functions.py
setLogRecordFactory(factory)
¶
Set the factory to be used for creating log records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory
|
type[LogRecord]
|
A callable that creates LogRecord instances |
required |
setLoggerClass(klass)
¶
uninstall()
¶
Restore the standard logging module.
This undoes the monkey-patching done by _install().