rs_dpr_service/utils/logging.md¶
Logging utility.
CustomFormatter
¶
Bases: Formatter
Custom logging formatter with colored text. See: https://stackoverflow.com/a/56944256
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
JobLogHandler
¶
Bases: Handler
Custom log handler that stores Dask worker logs in per job buffers for SSE streaming.
emit() is called from the dask Client IO thread (see dask_client.forward_logging), not from the asyncio event loop serving the SSE endpoint. asyncio objects are not thread-safe, so the buffers are protected by a lock and the SSE subscribers are woken up with loop.call_soon_threadsafe.
Logs are kept in memory (bounded) even with no subscriber, so a client connecting late or reconnecting after a network error can resume from its last received message index.
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
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 | |
job_ids
property
¶
Return the IDs of the jobs that have buffered logs.
clear(job_id)
¶
get_logs(job_id, start=0)
¶
Return the (index, message) of the buffered job logs with an index >= start.
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
subscribe(job_id)
¶
Return an asyncio Event that is set each time a new log is received for the job. Must be called from the event loop that will wait on the Event.
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
unsubscribe(job_id, event)
¶
Unregister an Event returned by subscribe()
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
Logging
¶
Logging utility.
Attributes:
| Name | Type | Description |
|---|---|---|
lock |
For code synchronization |
|
level |
Minimal log level to use for all new logging instances. |
Source code in docs/rs-dpr-service/rs_dpr_service/utils/logging.py
default(name='rspy')
classmethod
¶
Return a default Logger class instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name. You can pass name to use your current module name. |
'rspy'
|