Commit | Line | Data |
---|---|---|
0235b0db | 1 | # SPDX-License-Identifier: MIT |
811644b8 PP |
2 | # |
3 | # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> | |
811644b8 | 4 | |
493d384f | 5 | from bt2 import native_bt |
811644b8 PP |
6 | |
7 | ||
8 | class LoggingLevel: | |
ef267d12 | 9 | TRACE = native_bt.LOGGING_LEVEL_TRACE |
811644b8 PP |
10 | DEBUG = native_bt.LOGGING_LEVEL_DEBUG |
11 | INFO = native_bt.LOGGING_LEVEL_INFO | |
770538dd | 12 | WARNING = native_bt.LOGGING_LEVEL_WARNING |
811644b8 PP |
13 | ERROR = native_bt.LOGGING_LEVEL_ERROR |
14 | FATAL = native_bt.LOGGING_LEVEL_FATAL | |
15 | NONE = native_bt.LOGGING_LEVEL_NONE | |
16 | ||
17 | ||
18 | def get_minimal_logging_level(): | |
19 | return native_bt.logging_get_minimal_level() | |
20 | ||
21 | ||
22 | def get_global_logging_level(): | |
23 | return native_bt.logging_get_global_level() | |
24 | ||
25 | ||
26 | def set_global_logging_level(level): | |
27 | levels = ( | |
ef267d12 | 28 | LoggingLevel.TRACE, |
811644b8 PP |
29 | LoggingLevel.DEBUG, |
30 | LoggingLevel.INFO, | |
770538dd | 31 | LoggingLevel.WARNING, |
811644b8 PP |
32 | LoggingLevel.ERROR, |
33 | LoggingLevel.FATAL, | |
34 | LoggingLevel.NONE, | |
35 | ) | |
36 | ||
37 | if level not in levels: | |
38 | raise TypeError("'{}' is not a valid logging level".format(level)) | |
39 | ||
40 | return native_bt.logging_set_global_level(level) |