diff --git a/README.md b/README.md index 03527d5..e3bab89 100644 --- a/README.md +++ b/README.md @@ -1456,9 +1456,9 @@ lock.acquire() ... lock.release() ``` -or + +#### Or: ```python -lock = RLock() with lock: ... ``` @@ -1767,15 +1767,15 @@ from loguru import logger ```python logger.add('debug_{time}.log', colorize=True) # Connects a log file. logger.add('error_{time}.log', level='ERROR') # Another file for errors or higher. -logger.('A logging message') +logger.('A logging message.') ``` * **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.** ```python try: ... -except Exception as e: - logger.exception('An error happened', e) +except : + logger.exception('An error happened.') ``` ### Rotation diff --git a/index.html b/index.html index 39742c2..59533e4 100644 --- a/index.html +++ b/index.html @@ -1040,8 +1040,8 @@ cwd = Path() <str> = os.popen(<command>).read()

Subprocess

-
>>> import subprocess
->>> a = subprocess.run(['ls', '-a'], stdout=subprocess.PIPE)
+
>>> import subprocess, shlex
+>>> a = subprocess.run(shlex.split('ls -a'), stdout=subprocess.PIPE)
 >>> a.stdout
 b'.\n..\nfile1.txt\nfile2.txt\n'
 >>> a.returncode
@@ -1207,6 +1207,10 @@ lock.acquire()
 ...
 lock.release()
 
+

Or:

+
with lock:
+    ...
+

#Introspection

Inspecting code at runtime.

Variables

@@ -1241,7 +1245,7 @@ param_names = list(<sig>.parameters.keys()) attrs['a'] = 'abcde' return type(name, parents, attrs)
-

Or:

+

Or:

class MyMetaClass(type):
     def __new__(cls, name, parents, attrs):
         attrs['a'] = 'abcde'
@@ -1441,11 +1445,16 @@ pyplot.show()
 
logger.add('debug_{time}.log', colorize=True)  # Connects a log file.
 logger.add('error_{time}.log', level='ERROR')  # Another file for errors or higher.
-logger.<level>('A logging message')
+logger.<level>('A logging message.')
 
  • Levels: 'debug', 'info', 'success', 'warning', 'error', 'critical'.
+
try:
+    ...
+except <Exception>:
+    logger.exception('An error happened.')
+

Rotation

Parameter that sets a condition when a new log file is created.

rotation=<int>|<datetime.timedelta>|<datetime.time>|<str>