forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dexter] Add a simple logging class to Dexter
Adds a basic logging class to Dexter that uses the existing PrettyOutput class for printing and supports 3 levels of verbosity (note, warning, error). Intended to consolidate the logging logic for Dexter into one place, removing the need for conditional log statements and making it easier for us later if we wish to use a more complete logging class. Reviewed By: Orlando Differential Revision: https://reviews.llvm.org/D144983
- Loading branch information
Showing
9 changed files
with
71 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
cross-project-tests/debuginfo-tests/dexter/dex/utils/Logging.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# DExTer : Debugging Experience Tester | ||
# ~~~~~~ ~ ~~ ~ ~~ | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
"""Utility functions for producing command line warnings.""" | ||
|
||
from dex.utils import PrettyOutput | ||
|
||
class Logger(object): | ||
def __init__(self, pretty_output: PrettyOutput): | ||
self.o = pretty_output | ||
self.error_color = self.o.red | ||
self.warning_color = self.o.yellow | ||
self.note_color = self.o.default | ||
self.verbosity = 1 | ||
|
||
def error(self, msg, enable_prefix=True, flag=None): | ||
if self.verbosity < 0: | ||
return | ||
if enable_prefix: | ||
msg = f'error: {msg}' | ||
if flag: | ||
msg = f'{msg} <y>[{flag}]</>' | ||
self.error_color('{}\n'.format(msg), stream=PrettyOutput.stderr) | ||
|
||
def warning(self, msg, enable_prefix=True, flag=None): | ||
if self.verbosity < 1: | ||
return | ||
if enable_prefix: | ||
msg = f'warning: {msg}' | ||
if flag: | ||
msg = f'{msg} <y>[{flag}]</>' | ||
self.warning_color('{}\n'.format(msg), stream=PrettyOutput.stderr) | ||
|
||
def note(self, msg, enable_prefix=True, flag=None): | ||
if self.verbosity < 2: | ||
return | ||
if enable_prefix: | ||
msg = f'note: {msg}' | ||
if flag: | ||
msg = f'{msg} <y>[{flag}]</>' | ||
self.note_color('{}\n'.format(msg), stream=PrettyOutput.stderr) |
18 changes: 0 additions & 18 deletions
18
cross-project-tests/debuginfo-tests/dexter/dex/utils/Warning.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters