Skip to content

Commit 3b3ef77

Browse files
committed
Added logging
1 parent 6870769 commit 3b3ef77

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,46 @@ def get_border(screen):
16571657
```
16581658

16591659

1660+
Logging
1661+
-------
1662+
```python
1663+
# $ pip3 install loguru
1664+
from loguru import logger
1665+
```
1666+
1667+
```python
1668+
logger.add('debug_{time}.log', colorize=True) # Connects a log file.
1669+
logger.add('error_{time}.log', level='ERROR') # Adds another file for errors or higher.
1670+
logger.<level>('A logging message')
1671+
```
1672+
* **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical`'.**
1673+
1674+
### Rotation
1675+
Parameter that sets a condition when a new log file is created.
1676+
```python
1677+
rotation=<int>|<datetime.timedelta>|<datetime.time>|<str>
1678+
```
1679+
* **`'<int>'` - Max file size in bytes.**
1680+
* **`'<timedelta>`' - Max age of a file.**
1681+
* **`'<time>`' - Time of day.**
1682+
* **`'<str>'` - Any of above as string: '100 MB', '0.5 GB', '1 month 2 weeks', '4 days', '10h', 'monthly', '18:00', 'sunday', 'w0', 'monday at 12:00', ...**
1683+
1684+
### Retention
1685+
Sets a condition which old log files are deleted.
1686+
```python
1687+
retention=<int>|<datetime.timedelta>|<str>
1688+
```
1689+
* **`'<int>'` - Max number of files.**
1690+
* **`'<timedelta>`' - Max age of a file.**
1691+
* **`'<str>'` - Max age as string: '1 week, 3 days', '2 months', ...**
1692+
1693+
### Compression
1694+
Sets how inactive log files are compressed.
1695+
```python
1696+
compression='gz'|'bz2'|'tar'|'tar.gz'|'tar.bz2'|'zip'
1697+
```
1698+
1699+
16601700
Scraping
16611701
--------
16621702
```python

0 commit comments

Comments
 (0)