Skip to content

Commit 82c4d36

Browse files
committed
1.3.2 global mode function + more tests alongside it. Also improved the README to be more catchy
1 parent 405238f commit 82c4d36

File tree

6 files changed

+87
-7
lines changed

6 files changed

+87
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.3.2] - 2026-03-24
4+
5+
### Added
6+
- set_mode() for setting the mode globally (f.e to education)
7+
- More tests for the global mode setting
8+
9+
### Improved
10+
- README examples
11+
312
## [1.3.1] - 2026-03-24
413

514
### Added

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
![PyPI](https://img.shields.io/pypi/v/logeye?cachebust=1774326290)
1+
![PyPI](https://img.shields.io/pypi/v/logeye?cachebust=1774332497)
22
![Python](https://img.shields.io/pypi/pyversions/logeye)
33
![License](https://img.shields.io/github/license/MattFor/LogEye)
44

55
# LogEye
66

77
Understand exactly what your code is doing in real time, no debugger needed.
8+
89
LogEye is a frictionless runtime logger for Python that shows variable changes, function calls, and data mutations as
910
they happen.
1011

@@ -150,8 +151,7 @@ Instead of raw internal logs, it shows:
150151
Enable it with:
151152

152153
```python
153-
from logeye import log
154-
from logeye.config import set_mode
154+
from logeye import log, set_mode
155155

156156
# Globally
157157
set_mode("edu")
@@ -696,5 +696,5 @@ MIT License © 2026
696696

697697
See [LICENSE](LICENSE) for details.
698698

699-
Version 1.3.1
699+
Version 1.3.2
700700

logeye/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .core import log, watch
55
from .formatting import set_output_formatter, reset_output_formatter
66
from .config import toggle_logs, toggle_decorator_log_only, toggle_message_metadata, toggle_global_log_file, \
7-
set_path_mode, set_global_log_file, _normalize_mode
7+
set_mode, set_path_mode, set_global_log_file, _normalize_mode
88

99
w = watch
1010

@@ -21,6 +21,7 @@
2121
"toggle_message_metadata",
2222
"toggle_decorator_log_only",
2323

24+
"set_mode",
2425
"set_path_mode",
2526
"set_global_log_file",
2627
"set_output_formatter",

logeye/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ def toggle_message_metadata(enabled: bool):
7070
# SETTERS
7171
# =========
7272

73+
def set_mode(mode: str):
74+
"""
75+
Set global logging mode
76+
full or edu / educational
77+
"""
78+
79+
global _LOG_MODE
80+
_LOG_MODE = _normalize_mode(mode)
81+
82+
7383
def set_global_log_file(filepath):
7484
"""
7585
Route LogEye output to this file globally.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "logeye"
7-
version = "1.3.1"
7+
version = "1.3.2"
88
description = "Frictionless runtime logging for Python variables and functions"
99
readme = "README.md"
1010
requires-python = ">=3.10"

tests/test_educational.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from logeye import log
1+
from logeye import log, set_mode
22

33

44
def test_call_formatting(capsys):
@@ -191,3 +191,63 @@ def simple():
191191
assert "Added 1 to the end of arr" in out
192192
assert "Added 2 to arr" in out
193193
assert "Final: [3, 1, 2]" in out
194+
195+
196+
def test_global_mode_full(capsys):
197+
set_mode("full")
198+
199+
try:
200+
@log
201+
def foo():
202+
return 1
203+
204+
foo()
205+
206+
out = capsys.readouterr().out
207+
208+
assert "(call)" in out
209+
assert "Calling" not in out
210+
finally:
211+
set_mode("full")
212+
213+
214+
def test_global_mode_edu(capsys):
215+
set_mode("edu")
216+
217+
try:
218+
@log
219+
def foo():
220+
return 1
221+
222+
foo()
223+
224+
out = capsys.readouterr().out
225+
226+
assert "Calling foo()" in out
227+
assert "(call)" not in out
228+
finally:
229+
set_mode("full")
230+
231+
232+
def test_mode_toggle_mid_execution(capsys):
233+
set_mode("full")
234+
235+
try:
236+
@log
237+
def foo():
238+
a = 1 # full mode
239+
set_mode("edu")
240+
b = 2 # edu mode
241+
set_mode("full")
242+
c = 3 # back to full
243+
244+
foo()
245+
246+
out = capsys.readouterr().out
247+
248+
assert "(set)" in out or "foo.a" in out
249+
assert "(set)" in out or "foo.c" in out
250+
assert "b = 2" in out
251+
252+
finally:
253+
set_mode("full")

0 commit comments

Comments
 (0)