You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The magpylib-material-response package uses structured logging with [Loguru](https://loguru.readthedocs.io/) to provide informative messages about computation progress and debugging information.
4
+
5
+
## Default Behavior
6
+
7
+
By default, the library **does not output any log messages**. This follows best practices for Python libraries to avoid cluttering user output unless explicitly requested.
8
+
9
+
## Enabling Logging
10
+
11
+
To see log messages from the library, you need to configure logging:
12
+
13
+
```python
14
+
from magpylib_material_response import configure_logging
15
+
from magpylib_material_response.demag import apply_demag
16
+
17
+
# Enable logging with default settings (INFO level, colored output to stderr)
18
+
configure_logging()
19
+
20
+
# Now use the library - you'll see progress messages
21
+
# ... your code here
22
+
```
23
+
24
+
## Configuration Options
25
+
26
+
### Log Level
27
+
```python
28
+
from magpylib_material_response import configure_logging
29
+
30
+
# Set to DEBUG for detailed internal operations
31
+
configure_logging(level="DEBUG")
32
+
33
+
# Set to WARNING to only see important warnings and errors
34
+
configure_logging(level="WARNING")
35
+
36
+
# Available levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
37
+
```
38
+
39
+
### Output Destination
40
+
```python
41
+
import sys
42
+
from magpylib_material_response import configure_logging
43
+
44
+
# Output to stdout instead of stderr
45
+
configure_logging(sink=sys.stdout)
46
+
47
+
# Output to a file
48
+
configure_logging(sink="/path/to/logfile.log")
49
+
```
50
+
51
+
### Disable Colors and Time
52
+
```python
53
+
from magpylib_material_response import configure_logging
54
+
55
+
# Disable colored output (useful for log files)
56
+
configure_logging(enable_colors=False)
57
+
58
+
# Disable timestamps
59
+
configure_logging(show_time=False)
60
+
```
61
+
62
+
## Environment Variables
63
+
64
+
You can also configure logging using environment variables:
65
+
66
+
```bash
67
+
# Set log level
68
+
export MAGPYLIB_LOG_LEVEL=DEBUG
69
+
70
+
# Disable colors
71
+
export MAGPYLIB_LOG_COLORS=false
72
+
73
+
# Disable timestamps
74
+
export MAGPYLIB_LOG_TIME=false
75
+
```
76
+
77
+
## Disabling Logging
78
+
79
+
To completely disable logging output:
80
+
81
+
```python
82
+
from magpylib_material_response import disable_logging
83
+
84
+
disable_logging()
85
+
```
86
+
87
+
## Example Usage
88
+
89
+
```python
90
+
import magpylib as magpy
91
+
from magpylib_material_response import configure_logging
92
+
from magpylib_material_response.demag import apply_demag
93
+
from magpylib_material_response.meshing import mesh_Cuboid
0 commit comments