<Handler>.setFormatter(<Formatter>) <spanclass="hljs-comment"># Adds Formatter to the Handler.</span>
<Handler>.setLevel(<int/str>) <spanclass="hljs-comment"># Processes all messages by default.</span>
<Logger>.addHandler(<Handler>) <spanclass="hljs-comment"># Adds Handler to the Logger.</span>
<Logger>.setLevel(<int/str>) <spanclass="hljs-comment"># What is sent to its/ancestor's handlers.</span>
<Logger>.setLevel(<int/str>) <spanclass="hljs-comment"># What is sent to its/ancestors' handlers.</span>
<Logger>.propagate = <bool><spanclass="hljs-comment"># Cuts off ancestors' handlers if false.</span>
</code></pre>
<ul>
<li><strong>Parent logger can be specified by naming the child logger <codeclass="python hljs"><spanclass="hljs-string">'<parent>.<name>'</span></code>.</strong></li>
<div><h4id="createsaloggerthatwritesallmessagestofileandsendsthemtotherootshandlerthatprintswarningsorhigher">Creates a logger that writes all messages to file and sends them to the root's handler that prints warnings or higher:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>logger = logging.getLogger(<spanclass="hljs-string">'my_module'</span>)
<dict> = vars(<object>) <spanclass="hljs-comment"># Dict of writable attributes. Also <obj>.__dict__.</span>
<bool> = hasattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Checks if getattr() raises an AttributeError.</span>
value = getattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Raises AttributeError if attribute is missing.</span>
value = getattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Default value can be passed as the third argument.</span>
setattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>, value) <spanclass="hljs-comment"># Only works on objects with '__dict__' attribute.</span>
delattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Same. Also `del <object>.<attr_name>`.</span>