out 0.79__tar.gz → 0.80__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: out
3
- Version: 0.79
3
+ Version: 0.80
4
4
  Summary: Fun take on logging for non-huge projects. Gets "outta" the way.
5
5
  Home-page: https://github.com/mixmastamyk/out
6
6
  Author: Mike Miller
@@ -432,6 +432,20 @@ lexer+formatter:
432
432
  (Imagine with lovely ANSI flavors. 😁)
433
433
 
434
434
 
435
+ Performance
436
+ -----------------
437
+
438
+ out does quite a few things,
439
+ but it tries not to do any duplicate work or anything excessively stupid.
440
+ It takes about 25 microseconds to log a simple message,
441
+ or ~90 for a complex highlighted one on a newer machine.
442
+ Had to run a loop several thousand times (only logging) before it added up to
443
+ a noticeable delay.
444
+
445
+ Theming and highlighting are easy to turn off for production mode,
446
+ so "out" should hopefully not slow you down at all when not developing.
447
+
448
+
435
449
  Tips
436
450
  ---------
437
451
 
@@ -407,6 +407,20 @@ lexer+formatter:
407
407
  (Imagine with lovely ANSI flavors. 😁)
408
408
 
409
409
 
410
+ Performance
411
+ -----------------
412
+
413
+ out does quite a few things,
414
+ but it tries not to do any duplicate work or anything excessively stupid.
415
+ It takes about 25 microseconds to log a simple message,
416
+ or ~90 for a complex highlighted one on a newer machine.
417
+ Had to run a loop several thousand times (only logging) before it added up to
418
+ a noticeable delay.
419
+
420
+ Theming and highlighting are easy to turn off for production mode,
421
+ so "out" should hopefully not slow you down at all when not developing.
422
+
423
+
410
424
  Tips
411
425
  ---------
412
426
 
@@ -22,7 +22,7 @@ from .themes import (render_themes as _render_themes,
22
22
  render_styles as _render_styles,
23
23
  icons as _icons)
24
24
 
25
- __version__ = '0.79'
25
+ __version__ = '0.80'
26
26
 
27
27
  # Allow string as well as constant access. Levels will be added below:
28
28
  level_map = {
@@ -185,12 +185,7 @@ def add_logging_level(name, value, method_name=None):
185
185
  if self.isEnabledFor(value):
186
186
  self._log(value, message, args, stacklevel=2, **kwargs)
187
187
 
188
- #~ def logToRoot(message, *args, **kwargs): # may not need
189
- #~ logging.log(value, message, *args, **kwargs)
190
-
191
- # set functions
192
188
  setattr(logging.getLoggerClass(), method_name, log_for_level)
193
- #~ setattr(logging, method_name, logToRoot)
194
189
 
195
190
 
196
191
  def _add_handler(out_file, is_a_tty, level, theme='auto'):
@@ -27,6 +27,12 @@ def test_levels(full=True):
27
27
 
28
28
 
29
29
  out.warn('begin...')
30
+ print('⏵⏵ hide, should be nothing here:')
31
+ out.trace('trace msg: %s', 'Absurdly voluminous details…')
32
+ out.debug('debug message')
33
+ out.info('note message - Important positive feedback to remember.')
34
+ print('---------------------------------')
35
+
30
36
  print('⏵⏵ print std config:')
31
37
  out.configure(
32
38
  level='trace', # needs to go before to allow console log to be viewed!
@@ -0,0 +1,41 @@
1
+ '''
2
+ out - Simple logging with a few fun features.
3
+ © 2018-25, Mike Miller - Released under the LGPL, version 3+.
4
+ '''
5
+ from console.constants import TermLevel
6
+ from console.detection import init, is_a_tty, is_fbterm, os_name
7
+ from console.style import ForegroundPalette, BackgroundPalette, EffectsPalette
8
+
9
+
10
+ def _find_palettes(stream):
11
+ ''' Need to configure palettes manually, since we are checking stderr. '''
12
+ # doing this manually because we're using std-error, may be other reasons
13
+ is_tty = is_a_tty(stream)
14
+
15
+ try: # avoid install issue with new pip:2024 :-/
16
+ import env
17
+ except ModuleNotFoundError as err:
18
+ print(str(err))
19
+
20
+ # detection is performed if not explicitly disabled
21
+ if is_tty and (
22
+ env.PY_CONSOLE_AUTODETECT.value is None or
23
+ env.PY_CONSOLE_AUTODETECT.truthy
24
+ ):
25
+ level = init(_stream=stream)
26
+ fg = ForegroundPalette(level=level)
27
+ bg = BackgroundPalette(level=level)
28
+ fx = EffectsPalette(level=level)
29
+
30
+ else:
31
+ from console.constants import TermLevel
32
+ from console.disabled import empty_bin as _empty_bin
33
+
34
+ # Define pass-thru palette objects for streams and dumb terminals:
35
+ level = TermLevel.DUMB
36
+ fg = bg = fx = _empty_bin
37
+
38
+ return fg, bg, fx, level, is_tty
39
+
40
+
41
+ TermLevel, is_fbterm, os_name # quiet pyflakes
@@ -134,20 +134,15 @@ class ColorFormatter(logging.Formatter):
134
134
  message = record.msg.format(*record.args)
135
135
 
136
136
  # decide to highlight w/ pygments
137
- # TODO: Highlight args directly and drop text scan? - didn't work well.
138
137
  if self._highlight:
139
- if message.find('\x1b', 0, DATA_SEARCH_LIMIT) > -1:
140
- pass # found escape, avoid ANSI
141
- else:
142
- match = self.data_search(message, 0, DATA_SEARCH_LIMIT)
143
- if match:
144
- pos = match.start()
145
- front, back = message[:pos], message[pos:] # Spliten-Sie
146
- if front.endswith('\n'): # indent data?
147
- back = pformat(record.args)
148
- back = left_indent(back, self._code_indent)
149
- back = self._highlight(back, self._lexer, self._hl_fmtr)
150
- message = f'{front}{back}'
138
+ if match := self.data_search(message, 0, DATA_SEARCH_LIMIT):
139
+ pos = match.start()
140
+ front, back = message[:pos], message[pos:] # Spliten-Sie
141
+ if front.endswith('\n'): # indent data?
142
+ back = pformat(record.args)
143
+ back = left_indent(back, self._code_indent)
144
+ back = self._highlight(back, self._lexer, self._hl_fmtr)
145
+ message = f'{front}{back}'
151
146
 
152
147
  # style the level, icon
153
148
  record.message = message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: out
3
- Version: 0.79
3
+ Version: 0.80
4
4
  Summary: Fun take on logging for non-huge projects. Gets "outta" the way.
5
5
  Home-page: https://github.com/mixmastamyk/out
6
6
  Author: Mike Miller
@@ -432,6 +432,20 @@ lexer+formatter:
432
432
  (Imagine with lovely ANSI flavors. 😁)
433
433
 
434
434
 
435
+ Performance
436
+ -----------------
437
+
438
+ out does quite a few things,
439
+ but it tries not to do any duplicate work or anything excessively stupid.
440
+ It takes about 25 microseconds to log a simple message,
441
+ or ~90 for a complex highlighted one on a newer machine.
442
+ Had to run a loop several thousand times (only logging) before it added up to
443
+ a noticeable delay.
444
+
445
+ Theming and highlighting are easy to turn off for production mode,
446
+ so "out" should hopefully not slow you down at all when not developing.
447
+
448
+
435
449
  Tips
436
450
  ---------
437
451
 
out-0.79/out/detection.py DELETED
@@ -1,20 +0,0 @@
1
- '''
2
- out - Simple logging with a few fun features.
3
- © 2018-25, Mike Miller - Released under the LGPL, version 3+.
4
- '''
5
- from console.constants import TermLevel
6
- from console.detection import init, is_a_tty, is_fbterm, os_name
7
- from console.style import ForegroundPalette, BackgroundPalette, EffectsPalette
8
-
9
-
10
- def _find_palettes(stream):
11
- ''' Need to configure palettes manually, since we are checking stderr. '''
12
- level = init(_stream=stream)
13
- fg = ForegroundPalette(level=level)
14
- bg = BackgroundPalette(level=level)
15
- fx = EffectsPalette(level=level)
16
-
17
- return fg, bg, fx, level, is_a_tty(stream)
18
-
19
-
20
- TermLevel, is_fbterm, os_name # quiet pyflakes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes