cjnfuncs 3.2.1__tar.gz → 3.2.2__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.4
2
2
  Name: cjnfuncs
3
- Version: 3.2.1
3
+ Version: 3.2.2
4
4
  Summary: A collection of core functions for tool script writing
5
5
  Author-email: Chris Nelson <github@cjnaz.com>
6
6
  License-Expression: MIT
@@ -60,6 +60,12 @@ Project repo: https://github.com/cjnaz/cjnfuncs
60
60
 
61
61
  ## Key changes since the prior major public release (version 3.0)
62
62
 
63
+ 3.2.2 change
64
+ - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
65
+
66
+ 3.2.1 change
67
+ - periodic_log returns True/False whether call was logged - useful for follow on code that needs to run if the logging event happened.
68
+
63
69
  3.2 changes
64
70
  - `persistent_config` - Layered on top of config_item, this new class provides a clean and simple tool for carrying runtime data across tool
65
71
  script restarts and system reboots.
@@ -89,6 +95,8 @@ or using `core.set_logging_level(logging.INFO, 'cjnfuncs.configman')`.
89
95
 
90
96
  ## Revision history
91
97
 
98
+ - 3.2.2 - 261002 - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
99
+ - 3.2.1 - 260526 - periodic_log now returns True/False whether the the call was logged. Minor changes in resourcelock.
92
100
  - 3.2 - 260506 - New features: persistent_config and shared memory block handling
93
101
  - 3.1.1 260207 - separate resourcelock_islocked logger, get_next_dt days/weeks offset
94
102
  - 3.1 251109
@@ -40,6 +40,12 @@ Project repo: https://github.com/cjnaz/cjnfuncs
40
40
 
41
41
  ## Key changes since the prior major public release (version 3.0)
42
42
 
43
+ 3.2.2 change
44
+ - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
45
+
46
+ 3.2.1 change
47
+ - periodic_log returns True/False whether call was logged - useful for follow on code that needs to run if the logging event happened.
48
+
43
49
  3.2 changes
44
50
  - `persistent_config` - Layered on top of config_item, this new class provides a clean and simple tool for carrying runtime data across tool
45
51
  script restarts and system reboots.
@@ -69,6 +75,8 @@ or using `core.set_logging_level(logging.INFO, 'cjnfuncs.configman')`.
69
75
 
70
76
  ## Revision history
71
77
 
78
+ - 3.2.2 - 261002 - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
79
+ - 3.2.1 - 260526 - periodic_log now returns True/False whether the the call was logged. Minor changes in resourcelock.
72
80
  - 3.2 - 260506 - New features: persistent_config and shared memory block handling
73
81
  - 3.1.1 260207 - separate resourcelock_islocked logger, get_next_dt days/weeks offset
74
82
  - 3.1 251109
@@ -1,6 +1,7 @@
1
1
  [project]
2
2
  name = 'cjnfuncs'
3
- version = '3.2.1'
3
+ version = '3.2.2'
4
+ # 3.2.2 261002 Release - periodic_log [category - <package>.<module>.<function>(<line number>)]
4
5
  # 3.2.1 - Release
5
6
  # resourcelock info level log on lock unget request ignored if lock not owned by current process and not forced
6
7
  # resourcelock --verbose switch
@@ -4,7 +4,7 @@
4
4
 
5
5
  #==========================================================
6
6
  #
7
- # Chris Nelson, 2018-2025
7
+ # Chris Nelson, 2018-2026
8
8
  #
9
9
  # TODO Identification of the main module / tool script file may be wrong if a script imports a script that then imports cjnfuncs.
10
10
  #==========================================================
@@ -337,8 +337,8 @@ logging.ERROR (40), or logging.CRITICAL (50).
337
337
 
338
338
 
339
339
  ### Behaviors
340
- - NOTE that a child logger that has not been set to a logging level will have a logging level = 0, which Python seems to
341
- treat the same as logging.WARNING (30).
340
+ - NOTE that a child logger that has not been set to a logging level will have a logging level = 0. Python then
341
+ falls back to parent's logging level, etc., and if unset then falls back to the root logging level.
342
342
 
343
343
  """
344
344
 
@@ -400,7 +400,6 @@ values are on the stack or have previously been saved.
400
400
  return known_loggers[logger_name]
401
401
  except:
402
402
  return []
403
- return ll_history
404
403
 
405
404
 
406
405
  def pop_logging_level_stack(logger_name='', clear=False):
@@ -453,13 +452,18 @@ class _periodic_log:
453
452
  self.logger_name = logger_name
454
453
 
455
454
  def plog(self, message, log_level, cat):
456
- now_dt = datetime.datetime.now()
455
+ now_dt = datetime.datetime.now()
457
456
  if now_dt > self.next_dt:
458
457
  if log_level is None:
459
458
  log_level = self.log_level
460
- _logger = logging.getLogger(self.logger_name)
461
- _logger.log(log_level, f"[PLog-{cat}] {message}")
462
- self.next_dt = now_dt + self.log_interval
459
+ logger = logging.getLogger(self.logger_name)
460
+ frame = inspect.currentframe().f_back.f_back
461
+ module = inspect.getmodule(frame)
462
+ module_name = module.__name__ if module else None
463
+ func = frame.f_code.co_name
464
+ lineno = frame.f_lineno
465
+ logger.log(log_level, f"[{cat} - {module_name}.{func}({lineno})] {message}")
466
+ self.next_dt = now_dt + self.log_interval
463
467
  return True
464
468
  return False
465
469
 
@@ -471,6 +475,9 @@ def periodic_log(message, category='Cat1', logger_name='', log_interval='10m', l
471
475
  Log infrequently so as to avoid flooding the log. The `category` arg provides for independent
472
476
  log intervals for different types of logging events.
473
477
 
478
+ The log message is preceded with `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of
479
+ where the log event came from.
480
+
474
481
 
475
482
  ### Args
476
483
 
@@ -502,7 +509,8 @@ for this category (ignored of subsequent calls).
502
509
 
503
510
 
504
511
  ### Behaviors and rules
505
- - A call to periodic_log() returns a boolean (True/False) which may be used to gate further operations, such as sending a notification.
512
+ - A call to periodic_log() returns a boolean (True/False) which may be used to gate further operations, such as
513
+ sending a notification.
506
514
  """
507
515
  if category not in cats:
508
516
  if log_level is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cjnfuncs
3
- Version: 3.2.1
3
+ Version: 3.2.2
4
4
  Summary: A collection of core functions for tool script writing
5
5
  Author-email: Chris Nelson <github@cjnaz.com>
6
6
  License-Expression: MIT
@@ -60,6 +60,12 @@ Project repo: https://github.com/cjnaz/cjnfuncs
60
60
 
61
61
  ## Key changes since the prior major public release (version 3.0)
62
62
 
63
+ 3.2.2 change
64
+ - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
65
+
66
+ 3.2.1 change
67
+ - periodic_log returns True/False whether call was logged - useful for follow on code that needs to run if the logging event happened.
68
+
63
69
  3.2 changes
64
70
  - `persistent_config` - Layered on top of config_item, this new class provides a clean and simple tool for carrying runtime data across tool
65
71
  script restarts and system reboots.
@@ -89,6 +95,8 @@ or using `core.set_logging_level(logging.INFO, 'cjnfuncs.configman')`.
89
95
 
90
96
  ## Revision history
91
97
 
98
+ - 3.2.2 - 261002 - periodic_log output now includes `[category - <package>.<module>.<function>(<line number>)]` for debug traceability of where the log event came from.
99
+ - 3.2.1 - 260526 - periodic_log now returns True/False whether the the call was logged. Minor changes in resourcelock.
92
100
  - 3.2 - 260506 - New features: persistent_config and shared memory block handling
93
101
  - 3.1.1 260207 - separate resourcelock_islocked logger, get_next_dt days/weeks offset
94
102
  - 3.1 251109
File without changes
File without changes
File without changes
File without changes