Skip to content

Commit e1b821f

Browse files
committed
V6.0.1
1 parent c74b9aa commit e1b821f

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
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
285286
LOG_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

pythonLogs/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from importlib.metadata import version
33
from pythonLogs.core.constants import LogLevel, RotateWhen
44
from 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",
@@ -11,6 +11,7 @@
1111
"LogLevel",
1212
"RotateWhen",
1313
"clear_settings_cache",
14+
"get_log_settings",
1415
)
1516

1617
__title__ = "pythonLogs"

tests/core/test_settings.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,30 @@ def test_new_settings_after_env_change(self):
188188

189189

190190
class 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__

0 commit comments

Comments
 (0)