|
44 | 44 |
|
45 | 45 | DEFAULT_ANDROID_API = 14 |
46 | 46 |
|
| 47 | +class LevelDifferentiatingFormatter(logging.Formatter): |
| 48 | + def format(self, record): |
| 49 | + if record.levelno > 20: |
| 50 | + record.msg = '{}{}[WARNING]{}{}: '.format( |
| 51 | + Style.BRIGHT, Fore.RED, Fore.RESET, Style.RESET_ALL) + record.msg |
| 52 | + elif record.levelno > 10: |
| 53 | + record.msg = '{}[INFO]{}: '.format( |
| 54 | + Style.BRIGHT, Style.RESET_ALL) + record.msg |
| 55 | + else: |
| 56 | + record.msg = '{}{}[DEBUG]{}{}: '.format( |
| 57 | + Style.BRIGHT, Fore.LIGHTBLACK_EX, Fore.RESET, Style.RESET_ALL) + record.msg |
| 58 | + return super(LevelDifferentiatingFormatter, self).format(record) |
47 | 59 |
|
48 | 60 | logger = logging.getLogger('p4a') |
49 | 61 | if not hasattr(logger, 'touched'): # Necessary as importlib reloads |
|
52 | 64 | logger.setLevel(logging.INFO) |
53 | 65 | logger.touched = True |
54 | 66 | ch = logging.StreamHandler(stdout) |
55 | | - formatter = logging.Formatter('{}[%(levelname)s]{}: %(message)s'.format( |
56 | | - Style.BRIGHT, Style.RESET_ALL)) |
| 67 | + formatter = LevelDifferentiatingFormatter('%(message)s') |
57 | 68 | ch.setFormatter(formatter) |
58 | 69 | logger.addHandler(ch) |
59 | 70 | info = logger.info |
@@ -155,8 +166,8 @@ def wrapper_func(self, args): |
155 | 166 | user_ndk_ver=self.ndk_version) |
156 | 167 | dist = self._dist |
157 | 168 | if dist.needs_build: |
158 | | - info('No dist exists that meets your requirements, so one will ' |
159 | | - 'be built.') |
| 169 | + info_notify('No dist exists that meets your requirements, so one will ' |
| 170 | + 'be built.') |
160 | 171 | args = build_dist_from_args(ctx, dist, args) |
161 | 172 | func(self, args) |
162 | 173 | return wrapper_func |
|
0 commit comments