1
2#
3# spyne - Copyright (C) Spyne contributors.
4#
5# This library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# This library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public
16# License along with this library; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
18#
19
20"""You can use the constants in this package to add colour to your logs. You can
21use the "colorama" package to get ANSI colors working on windows.
22"""
23
24DARK_RED = ""
25"""ANSI colour value for dark red if colours are enabled, empty string
26otherwise."""
27
28LIGHT_GREEN = ""
29"""ANSI colour value for light green if colours are enabled, empty string
30otherwise."""
31
32LIGHT_RED = ""
33"""ANSI colour value for light red if colours are enabled, empty string
34otherwise."""
35
36LIGHT_BLUE = ""
37"""ANSI colour value for light blue if colours are enabled, empty string
38otherwise."""
39
40END_COLOR = ""
41"""ANSI colour value for end color marker if colours are enabled, empty string
42otherwise."""
43
44def enable_color():
45    """Enable colors by setting colour code constants to ANSI color codes."""
46
47    global LIGHT_GREEN
48    LIGHT_GREEN = "\033[1;32m"
49
50    global LIGHT_RED
51    LIGHT_RED = "\033[1;31m"
52
53    global LIGHT_BLUE
54    LIGHT_BLUE = "\033[1;34m"
55
56    global DARK_RED
57    DARK_RED = "\033[0;31m"
58
59    global END_COLOR
60    END_COLOR = "\033[0m"
61
62
63def disable_color():
64    """Disable colours by setting colour code constants to empty strings."""
65
66    global LIGHT_GREEN
67    LIGHT_GREEN = ""
68
69    global LIGHT_RED
70    LIGHT_RED = ""
71
72    global LIGHT_BLUE
73    LIGHT_BLUE = ""
74
75    global DARK_RED
76    DARK_RED = ""
77
78    global END_COLOR
79    END_COLOR = ""
80
81enable_color()
82