Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 586470ecbbb7
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a1cc03333158
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Sep 28, 2019

  1. Revert "Revert "cli: make output legible on black-on-white terminals …

    …too""
    
    This reverts commit 10661da.
    whitequark committed Sep 28, 2019
    Copy the full SHA
    611db6e View commit details
  2. Copy the full SHA
    a1cc033 View commit details
Showing with 12 additions and 4 deletions.
  1. +12 −4 software/glasgow/cli.py
16 changes: 12 additions & 4 deletions software/glasgow/cli.py
Original file line number Diff line number Diff line change
@@ -345,17 +345,25 @@ def _applet(revision, args):


class TerminalFormatter(logging.Formatter):
LOG_COLORS = {
"TRACE" : "\033[37m",
DEFAULT_COLORS = {
"TRACE" : "\033[0m",
"DEBUG" : "\033[36m",
"INFO" : "\033[1;37m",
"INFO" : "\033[1m",
"WARNING" : "\033[1;33m",
"ERROR" : "\033[1;31m",
"CRITICAL": "\033[1;41m",
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.colors = dict(self.DEFAULT_COLORS)
for color_override in os.getenv("GLASGOW_COLORS", "").split(":"):
if color_override:
level, color = color_override.split("=", 2)
self.colors[level] = "\033[{}m".format(color)

def format(self, record):
color = self.LOG_COLORS.get(record.levelname, "")
color = self.colors.get(record.levelname, "")
# glasgow.applet.foo → g.applet.foo
record.name = record.name.replace("glasgow.", "g.")
# applet.memory._25x → applet.memory.25x