1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
2 | # contributor license agreements. See the NOTICE file distributed with |
||
3 | # this work for additional information regarding copyright ownership. |
||
4 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
||
5 | # (the "License"); you may not use this file except in compliance with |
||
6 | # the License. You may obtain a copy of the License at |
||
7 | # |
||
8 | # http://www.apache.org/licenses/LICENSE-2.0 |
||
9 | # |
||
10 | # Unless required by applicable law or agreed to in writing, software |
||
11 | # distributed under the License is distributed on an "AS IS" BASIS, |
||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
13 | # See the License for the specific language governing permissions and |
||
14 | # limitations under the License. |
||
15 | |||
16 | """ |
||
17 | Module containing various debugging functionality. |
||
18 | """ |
||
19 | |||
20 | from __future__ import absolute_import |
||
21 | import paramiko |
||
22 | from kombu.utils.debug import setup_logging |
||
23 | |||
24 | import logging as stdlib_logging |
||
25 | |||
26 | from st2common.logging.misc import set_log_level_for_all_loggers |
||
27 | |||
28 | __all__ = [ |
||
29 | 'enable_debugging', |
||
30 | 'disable_debugging', |
||
31 | 'is_enabled' |
||
32 | ] |
||
33 | |||
34 | ENABLE_DEBUGGING = False |
||
35 | |||
36 | |||
37 | def enable_debugging(): |
||
38 | global ENABLE_DEBUGGING |
||
39 | ENABLE_DEBUGGING = True |
||
40 | |||
41 | # Set debug level for all StackStorm loggers |
||
42 | set_log_level_for_all_loggers(level=stdlib_logging.DEBUG) |
||
43 | |||
44 | # Set debug log level for kombu |
||
45 | setup_logging(loglevel=stdlib_logging.DEBUG) |
||
46 | |||
47 | # Set debug log level for paramiko |
||
48 | paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG) |
||
49 | |||
50 | return ENABLE_DEBUGGING |
||
51 | |||
52 | |||
53 | def disable_debugging(): |
||
54 | global ENABLE_DEBUGGING |
||
55 | ENABLE_DEBUGGING = False |
||
56 | |||
57 | set_log_level_for_all_loggers(level=stdlib_logging.INFO) |
||
58 | |||
59 | setup_logging(loglevel=stdlib_logging.INFO) |
||
60 | paramiko.common.logging.basicConfig(level=paramiko.common.INFO) |
||
61 | |||
62 | return ENABLE_DEBUGGING |
||
63 | |||
64 | |||
65 | def is_enabled(): |
||
66 | global ENABLE_DEBUGGING |
||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
67 | return ENABLE_DEBUGGING |
||
68 |