File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838- [ Context Manager Support] ( #context-manager-support )
3939- [ Using With Multiple Log Levels and Files] ( #using-with-multiple-log-levels-and-files )
4040- [ Environment Variables] ( #env-variables-optional )
41+ - [ Settings Cache Management] ( #settings-cache-management )
4142- [ Flexible Configuration Options] ( #flexible-configuration-options )
4243- [ Development] ( #development )
4344 - [ Create DEV Environment, Running Tests and Building Wheel] ( #create-dev-environment-running-tests-and-building-wheel )
@@ -285,6 +286,25 @@ LOG_ROTATE_AT_UTC=True
285286LOG_ROTATE_FILE_SUFIX="%Y%m%d"
286287```
287288
289+ ## Settings Cache Management
290+
291+ Use ` get_log_settings() ` to inspect current configuration and ` clear_settings_cache() ` to reload configuration from environment variables:
292+
293+ ``` python
294+ from pythonLogs import get_log_settings, clear_settings_cache
295+
296+ # Inspect current settings
297+ settings = get_log_settings()
298+ print (settings.level) # Current log level
299+ print (settings.timezone) # Current timezone
300+
301+ # Clear cache and reload .env on next access (default)
302+ clear_settings_cache()
303+
304+ # Clear cache but keep current .env values
305+ clear_settings_cache(reload_env = False )
306+ ```
307+
288308
289309
290310
Original file line number Diff line number Diff line change 22from importlib .metadata import version
33from pythonLogs .core .constants import LogLevel , RotateWhen
44from pythonLogs .core .factory import BasicLog , SizeRotatingLog , TimedRotatingLog
5- from pythonLogs .core .settings import clear_settings_cache
5+ from pythonLogs .core .settings import clear_settings_cache , get_log_settings
66
77__all__ = (
88 "BasicLog" ,
1111 "LogLevel" ,
1212 "RotateWhen" ,
1313 "clear_settings_cache" ,
14+ "get_log_settings" ,
1415)
1516
1617__title__ = "pythonLogs"
Original file line number Diff line number Diff line change @@ -188,17 +188,30 @@ def test_new_settings_after_env_change(self):
188188
189189
190190class TestPublicExports :
191- """Test that clear_settings_cache is exported from main module."""
191+ """Test that clear_settings_cache and get_log_settings are exported from main module."""
192192
193- def test_import_from_main_module (self ):
193+ def test_clear_settings_cache_import_from_main_module (self ):
194194 """Test that clear_settings_cache can be imported from pythonLogs."""
195195 from pythonLogs import clear_settings_cache as exported_func
196196 from pythonLogs .core .settings import clear_settings_cache as original_func
197197
198198 assert exported_func is original_func
199199
200- def test_in_all (self ):
200+ def test_clear_settings_cache_in_all (self ):
201201 """Test that clear_settings_cache is in __all__."""
202202 import pythonLogs
203203
204204 assert "clear_settings_cache" in pythonLogs .__all__
205+
206+ def test_get_log_settings_import_from_main_module (self ):
207+ """Test that get_log_settings can be imported from pythonLogs."""
208+ from pythonLogs import get_log_settings as exported_func
209+ from pythonLogs .core .settings import get_log_settings as original_func
210+
211+ assert exported_func is original_func
212+
213+ def test_get_log_settings_in_all (self ):
214+ """Test that get_log_settings is in __all__."""
215+ import pythonLogs
216+
217+ assert "get_log_settings" in pythonLogs .__all__
You can’t perform that action at this time.
0 commit comments