diff --git a/README.md b/README.md index 3850297..c3c61b7 100644 --- a/README.md +++ b/README.md @@ -2256,7 +2256,8 @@ logging.basicConfig( .setFormatter() # Adds Formatter to the Handler. .setLevel() # Processes all messages by default. .addHandler() # Adds Handler to the Logger. -.setLevel() # What is sent to its/ancestor's handlers. +.setLevel() # What is sent to its/ancestors' handlers. +.propagate = # Cuts off ancestors' handlers if false. ``` * **Parent logger can be specified by naming the child logger `'.'`.** * **If logger doesn't have a set level it inherits it from the first ancestor that does.** @@ -2267,10 +2268,10 @@ logging.basicConfig( ```python >>> logger = logging.getLogger('my_module') >>> handler = logging.FileHandler('test.log', encoding='utf-8') ->>> formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s') ->>> handler.setFormatter(formatter) +>>> handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')) >>> logger.addHandler(handler) ->>> logging.basicConfig(level='DEBUG') +>>> logger.setLevel('DEBUG') +>>> logging.basicConfig() >>> logging.root.handlers[0].setLevel('WARNING') >>> logger.critical('Running out of disk space.') CRITICAL:my_module:Running out of disk space. @@ -2291,7 +2292,7 @@ Introspection = dir() # Names of object's attributes (including methods). = vars() # Dict of writable attributes. Also .__dict__. = hasattr(, '') # Checks if getattr() raises an AttributeError. -value = getattr(, '') # Raises AttributeError if attribute is missing. +value = getattr(, '') # Default value can be passed as the third argument. setattr(, '', value) # Only works on objects with '__dict__' attribute. delattr(, '') # Same. Also `del .`. ``` diff --git a/index.html b/index.html index ba06850..5f5a8d5 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1862,7 +1862,8 @@ logging.debug/info/warning/error/critical(<str>) # Adds Formatter to the Handler. <Handler>.setLevel(<int/str>) # Processes all messages by default. <Logger>.addHandler(<Handler>) # Adds Handler to the Logger. -<Logger>.setLevel(<int/str>) # What is sent to its/ancestor's handlers. +<Logger>.setLevel(<int/str>) # What is sent to its/ancestors' handlers. +<Logger>.propagate = <bool> # Cuts off ancestors' handlers if false.
  • Parent logger can be specified by naming the child logger '<parent>.<name>'.
  • @@ -1872,10 +1873,10 @@ logging.debug/info/warning/error/critical(<str>) Creates a logger that writes all messages to file and sends them to the root's handler that prints warnings or higher:
    >>> logger = logging.getLogger('my_module')
     >>> handler = logging.FileHandler('test.log', encoding='utf-8')
    ->>> formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')
    ->>> handler.setFormatter(formatter)
    +>>> handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s'))
     >>> logger.addHandler(handler)
    ->>> logging.basicConfig(level='DEBUG')
    +>>> logger.setLevel('DEBUG')
    +>>> logging.basicConfig()
     >>> logging.root.handlers[0].setLevel('WARNING')
     >>> logger.critical('Running out of disk space.')
     CRITICAL:my_module:Running out of disk space.
    @@ -1891,7 +1892,7 @@ CRITICAL:my_module:Running out of disk space.
     
    <list> = dir(<object>)                     # Names of object's attributes (including methods).
     <dict> = vars(<object>)                    # Dict of writable attributes. Also <obj>.__dict__.
     <bool> = hasattr(<object>, '<attr_name>')  # Checks if getattr() raises an AttributeError.
    -value  = getattr(<object>, '<attr_name>')  # Raises AttributeError if attribute is missing.
    +value  = getattr(<object>, '<attr_name>')  # Default value can be passed as the third argument.
     setattr(<object>, '<attr_name>', value)    # Only works on objects with '__dict__' attribute.
     delattr(<object>, '<attr_name>')           # Same. Also `del <object>.<attr_name>`.
     
    @@ -2936,7 +2937,7 @@ $ deactivate # Deactivates the activ
    - +
    diff --git a/parse.js b/parse.js index 181ec93..d99d15c 100755 --- a/parse.js +++ b/parse.js @@ -218,10 +218,10 @@ const PROGRESS_BAR = const LOGGING_EXAMPLE = '>>> logger = logging.getLogger(\'my_module\')\n' + '>>> handler = logging.FileHandler(\'test.log\', encoding=\'utf-8\')\n' + - '>>> formatter = logging.Formatter(\'%(asctime)s %(levelname)s:%(name)s:%(message)s\')\n' + - '>>> handler.setFormatter(formatter)\n' + + '>>> handler.setFormatter(logging.Formatter(\'%(asctime)s %(levelname)s:%(name)s:%(message)s\'))\n' + '>>> logger.addHandler(handler)\n' + - '>>> logging.basicConfig(level=\'DEBUG\')\n' + + '>>> logger.setLevel(\'DEBUG\')\n' + + '>>> logging.basicConfig()\n' + '>>> logging.root.handlers[0].setLevel(\'WARNING\')\n' + '>>> logger.critical(\'Running out of disk space.\')\n' + 'CRITICAL:my_module:Running out of disk space.\n' + @@ -832,7 +832,7 @@ function fixHighlights() { //$(`code:contains(import asyncio, collections, curses, curses.textpad, enum, random)`).html(COROUTINES); $(`code:contains(import curses, os)`).html(CURSES); $(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR); - $(`code:contains(>>> logging.basicConfig(level=)`).html(LOGGING_EXAMPLE); + $(`code:contains(>>> logging.basicConfig()`).html(LOGGING_EXAMPLE); $(`code:contains(samples_f = (sin(i *)`).html(AUDIO); $(`code:contains(collections, dataclasses, enum, io, itertools)`).html(MARIO); $(`code:contains(>>> gb = df.groupby)`).html(PLOTLY);