Total Complexity | 2 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Coverage | 77.78% |
Changes | 0 |
1 | """ |
||
2 | weitersager.util |
||
3 | ~~~~~~~~~~~~~~~~ |
||
4 | |||
5 | Utilities |
||
6 | |||
7 | :Copyright: 2007-2020 Jochen Kupperschmidt |
||
8 | :License: MIT, see LICENSE for details. |
||
9 | """ |
||
10 | |||
11 | 1 | from datetime import datetime |
|
12 | 1 | from threading import Thread |
|
13 | 1 | from typing import Any, Callable, Dict, Sequence |
|
14 | |||
15 | |||
16 | 1 | def log(message: str, *args: Any, **kwargs: Dict[str, Any]) -> None: |
|
17 | 1 | timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S') |
|
18 | 1 | print(timestamp, message.format(*args, **kwargs)) |
|
19 | |||
20 | |||
21 | 1 | def start_thread(target: Callable, name: str) -> None: |
|
22 | """Create, configure, and start a new thread.""" |
||
23 | t = Thread(target=target, name=name, daemon=True) |
||
24 | t.start() |
||
25 |