| 1 | # SPDX-License-Identifier: MIT |
| 2 | # |
| 3 | # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> |
| 4 | |
| 5 | from bt2 import native_bt |
| 6 | |
| 7 | |
| 8 | class LoggingLevel: |
| 9 | TRACE = native_bt.LOGGING_LEVEL_TRACE |
| 10 | DEBUG = native_bt.LOGGING_LEVEL_DEBUG |
| 11 | INFO = native_bt.LOGGING_LEVEL_INFO |
| 12 | WARNING = native_bt.LOGGING_LEVEL_WARNING |
| 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 = ( |
| 28 | LoggingLevel.TRACE, |
| 29 | LoggingLevel.DEBUG, |
| 30 | LoggingLevel.INFO, |
| 31 | LoggingLevel.WARNING, |
| 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) |