[{"data":1,"prerenderedAt":994},["ShallowReactive",2],{"content-query-r3uIBnjtvS":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"tags":10,"body":11,"_type":988,"_id":989,"_source":990,"_file":991,"_stem":992,"_extension":993},"/tutorials/python-logging","tutorials",false,"","The Python logging facility","We will use Python's logging to keep track of our code's execution.\nTo use a logger, just the following at the beginning of a script:","python",{"type":12,"children":13,"toc":986},"root",[14,31,98,180,185,198,751,764,769,980],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19,22,29],{"type":20,"value":21},"text","We will use Python's ",{"type":15,"tag":23,"props":24,"children":26},"code",{"className":25},[],[27],{"type":20,"value":28},"logging",{"type":20,"value":30}," to keep track of our code's execution.\nTo use a logger, just the following at the beginning of a script:",{"type":15,"tag":32,"props":33,"children":36},"pre",{"className":34,"code":35,"language":10,"meta":7,"style":7},"language-python shiki shiki-themes github-light monokai monokai github-light monokai","import logging\n\nlogger = logging.getLogger(__name__)\n",[37],{"type":15,"tag":23,"props":38,"children":39},{"__ignoreMap":7},[40,58,68],{"type":15,"tag":41,"props":42,"children":45},"span",{"class":43,"line":44},"line",1,[46,52],{"type":15,"tag":41,"props":47,"children":49},{"style":48},"--shiki-default:#D73A49;--shiki-dark-mode:#F92672;--shiki-sky-dark-mode:#F92672;--shiki-light-mode:#D73A49;--shiki-blue-mode:#F92672",[50],{"type":20,"value":51},"import",{"type":15,"tag":41,"props":53,"children":55},{"style":54},"--shiki-default:#24292E;--shiki-dark-mode:#F8F8F2;--shiki-sky-dark-mode:#F8F8F2;--shiki-light-mode:#24292E;--shiki-blue-mode:#F8F8F2",[56],{"type":20,"value":57}," logging\n",{"type":15,"tag":41,"props":59,"children":61},{"class":43,"line":60},2,[62],{"type":15,"tag":41,"props":63,"children":65},{"emptyLinePlaceholder":64},true,[66],{"type":20,"value":67},"\n",{"type":15,"tag":41,"props":69,"children":71},{"class":43,"line":70},3,[72,77,82,87,93],{"type":15,"tag":41,"props":73,"children":74},{"style":54},[75],{"type":20,"value":76},"logger ",{"type":15,"tag":41,"props":78,"children":79},{"style":48},[80],{"type":20,"value":81},"=",{"type":15,"tag":41,"props":83,"children":84},{"style":54},[85],{"type":20,"value":86}," logging.getLogger(",{"type":15,"tag":41,"props":88,"children":90},{"style":89},"--shiki-default:#005CC5;--shiki-dark-mode:#F8F8F2;--shiki-sky-dark-mode:#F8F8F2;--shiki-light-mode:#005CC5;--shiki-blue-mode:#F8F8F2",[91],{"type":20,"value":92},"__name__",{"type":15,"tag":41,"props":94,"children":95},{"style":54},[96],{"type":20,"value":97},")\n",{"type":15,"tag":16,"props":99,"children":100},{},[101,103,109,111,117,119,125,127,133,134,140,141,147,148,154,156,162,164,170,172,178],{"type":20,"value":102},"Then, think of ",{"type":15,"tag":23,"props":104,"children":106},{"className":105},[],[107],{"type":20,"value":108},"logger",{"type":20,"value":110}," as a replacement of the ",{"type":15,"tag":23,"props":112,"children":114},{"className":113},[],[115],{"type":20,"value":116},"print",{"type":20,"value":118}," function.\nLogging uses several levels to distinguish the importance of each message.\nThey are: ",{"type":15,"tag":23,"props":120,"children":122},{"className":121},[],[123],{"type":20,"value":124},"DEBUG",{"type":20,"value":126},", ",{"type":15,"tag":23,"props":128,"children":130},{"className":129},[],[131],{"type":20,"value":132},"INFO",{"type":20,"value":126},{"type":15,"tag":23,"props":135,"children":137},{"className":136},[],[138],{"type":20,"value":139},"WARNING",{"type":20,"value":126},{"type":15,"tag":23,"props":142,"children":144},{"className":143},[],[145],{"type":20,"value":146},"ERROR",{"type":20,"value":126},{"type":15,"tag":23,"props":149,"children":151},{"className":150},[],[152],{"type":20,"value":153},"CRITICAL",{"type":20,"value":155},".\nFor example, to issue a logger message for debug purposes, we use ",{"type":15,"tag":23,"props":157,"children":159},{"className":158},[],[160],{"type":20,"value":161},"logger.debug(\"This is a debug message\")",{"type":20,"value":163},".\nIf a message is just a piece of information, we use ",{"type":15,"tag":23,"props":165,"children":167},{"className":166},[],[168],{"type":20,"value":169},"logger.info(\"This message is info\")",{"type":20,"value":171},", if it's error, ",{"type":15,"tag":23,"props":173,"children":175},{"className":174},[],[176],{"type":20,"value":177},"logger.error(\"Error message\")",{"type":20,"value":179},", etc.",{"type":15,"tag":16,"props":181,"children":182},{},[183],{"type":20,"value":184},"The logging facility needs to be configured first, which we typically do through a config file. An example follows.",{"type":15,"tag":16,"props":186,"children":187},{},[188,190,196],{"type":20,"value":189},"File ",{"type":15,"tag":23,"props":191,"children":193},{"className":192},[],[194],{"type":20,"value":195},"logging_config.yaml",{"type":20,"value":197},":",{"type":15,"tag":32,"props":199,"children":201},{"className":34,"code":200,"language":10,"meta":7,"style":7},"version: 1\nformatters:\n  standard:\n    format: '%(asctime)s|%(name)s|%(levelname)s|%(message)s'\n\nhandlers:\n  console:\n    class: logging.StreamHandler\n    level: DEBUG\n    formatter: standard\n    stream: ext://sys.stdout\n  error_file:\n    class: fileHandlers.handlers.MakedirsRotatingFileHandler\n    level: ERROR\n    formatter: standard\n    filename: logs/errors.log\n    maxBytes: 10485760  # 10 MB\n    backupCount: 20\n    encoding: utf8\n  output_file:\n    class: fileHandlers.handlers.MakedirsRotatingFileHandler\n    level: NOTSET\n    formatter: standard\n    filename: logs/output.log\n    # maxBytes: 10485760  # 10 MB\n    backupCount: 20  # Rotates this many times when maxBytes is reached\n    encoding: utf8\nloggers:\n  __main__:  # Main module, the one you execute\n    level: DEBUG\n    # handlers: [console]\n    handlers: [error_file, output_file]\n    propagate: no  # Do not propagate to `root` level.\n  models:  # Set up logger for `models` module - change this to your module name\n    level: DEBUG\n    propagate: no\n  features:  # `features` module - change this to your current module name\n    level: DEBUG\n    handlers: [error_file, output_file]\n    propagate: no\nroot:\n  level: DEBUG\n  handlers: [console, error_file, output_file]\n",[202],{"type":15,"tag":23,"props":203,"children":204},{"__ignoreMap":7},[205,219,227,235,294,302,311,320,335,349,358,377,386,399,412,420,439,459,473,482,491,503,516,524,541,550,568,576,585,599,611,620,629,643,657,669,678,692,704,712,720,729,742],{"type":15,"tag":41,"props":206,"children":207},{"class":43,"line":44},[208,213],{"type":15,"tag":41,"props":209,"children":210},{"style":54},[211],{"type":20,"value":212},"version: ",{"type":15,"tag":41,"props":214,"children":216},{"style":215},"--shiki-default:#005CC5;--shiki-dark-mode:#AE81FF;--shiki-sky-dark-mode:#AE81FF;--shiki-light-mode:#005CC5;--shiki-blue-mode:#AE81FF",[217],{"type":20,"value":218},"1\n",{"type":15,"tag":41,"props":220,"children":221},{"class":43,"line":60},[222],{"type":15,"tag":41,"props":223,"children":224},{"style":54},[225],{"type":20,"value":226},"formatters:\n",{"type":15,"tag":41,"props":228,"children":229},{"class":43,"line":70},[230],{"type":15,"tag":41,"props":231,"children":232},{"style":54},[233],{"type":20,"value":234},"  standard:\n",{"type":15,"tag":41,"props":236,"children":238},{"class":43,"line":237},4,[239,245,250,256,261,266,271,275,280,284,289],{"type":15,"tag":41,"props":240,"children":242},{"style":241},"--shiki-default:#005CC5;--shiki-dark-mode:#66D9EF;--shiki-sky-dark-mode:#66D9EF;--shiki-light-mode:#005CC5;--shiki-blue-mode:#66D9EF",[243],{"type":20,"value":244},"    format",{"type":15,"tag":41,"props":246,"children":247},{"style":54},[248],{"type":20,"value":249},": ",{"type":15,"tag":41,"props":251,"children":253},{"style":252},"--shiki-default:#032F62;--shiki-dark-mode:#E6DB74;--shiki-sky-dark-mode:#E6DB74;--shiki-light-mode:#032F62;--shiki-blue-mode:#E6DB74",[254],{"type":20,"value":255},"'",{"type":15,"tag":41,"props":257,"children":258},{"style":215},[259],{"type":20,"value":260},"%(asctime)s",{"type":15,"tag":41,"props":262,"children":263},{"style":252},[264],{"type":20,"value":265},"|",{"type":15,"tag":41,"props":267,"children":268},{"style":215},[269],{"type":20,"value":270},"%(name)s",{"type":15,"tag":41,"props":272,"children":273},{"style":252},[274],{"type":20,"value":265},{"type":15,"tag":41,"props":276,"children":277},{"style":215},[278],{"type":20,"value":279},"%(levelname)s",{"type":15,"tag":41,"props":281,"children":282},{"style":252},[283],{"type":20,"value":265},{"type":15,"tag":41,"props":285,"children":286},{"style":215},[287],{"type":20,"value":288},"%(message)s",{"type":15,"tag":41,"props":290,"children":291},{"style":252},[292],{"type":20,"value":293},"'\n",{"type":15,"tag":41,"props":295,"children":297},{"class":43,"line":296},5,[298],{"type":15,"tag":41,"props":299,"children":300},{"emptyLinePlaceholder":64},[301],{"type":20,"value":67},{"type":15,"tag":41,"props":303,"children":305},{"class":43,"line":304},6,[306],{"type":15,"tag":41,"props":307,"children":308},{"style":54},[309],{"type":20,"value":310},"handlers:\n",{"type":15,"tag":41,"props":312,"children":314},{"class":43,"line":313},7,[315],{"type":15,"tag":41,"props":316,"children":317},{"style":54},[318],{"type":20,"value":319},"  console:\n",{"type":15,"tag":41,"props":321,"children":323},{"class":43,"line":322},8,[324,330],{"type":15,"tag":41,"props":325,"children":327},{"style":326},"--shiki-default:#D73A49;--shiki-dark-mode:#66D9EF;--shiki-sky-dark-mode:#66D9EF;--shiki-light-mode:#D73A49;--shiki-blue-mode:#66D9EF;--shiki-default-font-style:inherit;--shiki-dark-mode-font-style:italic;--shiki-sky-dark-mode-font-style:italic;--shiki-light-mode-font-style:inherit;--shiki-blue-mode-font-style:italic",[328],{"type":20,"value":329},"    class",{"type":15,"tag":41,"props":331,"children":332},{"style":54},[333],{"type":20,"value":334},": logging.StreamHandler\n",{"type":15,"tag":41,"props":336,"children":338},{"class":43,"line":337},9,[339,344],{"type":15,"tag":41,"props":340,"children":341},{"style":54},[342],{"type":20,"value":343},"    level: ",{"type":15,"tag":41,"props":345,"children":346},{"style":215},[347],{"type":20,"value":348},"DEBUG\n",{"type":15,"tag":41,"props":350,"children":352},{"class":43,"line":351},10,[353],{"type":15,"tag":41,"props":354,"children":355},{"style":54},[356],{"type":20,"value":357},"    formatter: standard\n",{"type":15,"tag":41,"props":359,"children":361},{"class":43,"line":360},11,[362,367,372],{"type":15,"tag":41,"props":363,"children":364},{"style":54},[365],{"type":20,"value":366},"    stream: ext:",{"type":15,"tag":41,"props":368,"children":369},{"style":48},[370],{"type":20,"value":371},"//",{"type":15,"tag":41,"props":373,"children":374},{"style":54},[375],{"type":20,"value":376},"sys.stdout\n",{"type":15,"tag":41,"props":378,"children":380},{"class":43,"line":379},12,[381],{"type":15,"tag":41,"props":382,"children":383},{"style":54},[384],{"type":20,"value":385},"  error_file:\n",{"type":15,"tag":41,"props":387,"children":389},{"class":43,"line":388},13,[390,394],{"type":15,"tag":41,"props":391,"children":392},{"style":326},[393],{"type":20,"value":329},{"type":15,"tag":41,"props":395,"children":396},{"style":54},[397],{"type":20,"value":398},": fileHandlers.handlers.MakedirsRotatingFileHandler\n",{"type":15,"tag":41,"props":400,"children":402},{"class":43,"line":401},14,[403,407],{"type":15,"tag":41,"props":404,"children":405},{"style":54},[406],{"type":20,"value":343},{"type":15,"tag":41,"props":408,"children":409},{"style":215},[410],{"type":20,"value":411},"ERROR\n",{"type":15,"tag":41,"props":413,"children":415},{"class":43,"line":414},15,[416],{"type":15,"tag":41,"props":417,"children":418},{"style":54},[419],{"type":20,"value":357},{"type":15,"tag":41,"props":421,"children":423},{"class":43,"line":422},16,[424,429,434],{"type":15,"tag":41,"props":425,"children":426},{"style":54},[427],{"type":20,"value":428},"    filename: logs",{"type":15,"tag":41,"props":430,"children":431},{"style":48},[432],{"type":20,"value":433},"/",{"type":15,"tag":41,"props":435,"children":436},{"style":54},[437],{"type":20,"value":438},"errors.log\n",{"type":15,"tag":41,"props":440,"children":442},{"class":43,"line":441},17,[443,448,453],{"type":15,"tag":41,"props":444,"children":445},{"style":54},[446],{"type":20,"value":447},"    maxBytes: ",{"type":15,"tag":41,"props":449,"children":450},{"style":215},[451],{"type":20,"value":452},"10485760",{"type":15,"tag":41,"props":454,"children":456},{"style":455},"--shiki-default:#6A737D;--shiki-dark-mode:#88846F;--shiki-sky-dark-mode:#88846F;--shiki-light-mode:#6A737D;--shiki-blue-mode:#88846F",[457],{"type":20,"value":458},"  # 10 MB\n",{"type":15,"tag":41,"props":460,"children":462},{"class":43,"line":461},18,[463,468],{"type":15,"tag":41,"props":464,"children":465},{"style":54},[466],{"type":20,"value":467},"    backupCount: ",{"type":15,"tag":41,"props":469,"children":470},{"style":215},[471],{"type":20,"value":472},"20\n",{"type":15,"tag":41,"props":474,"children":476},{"class":43,"line":475},19,[477],{"type":15,"tag":41,"props":478,"children":479},{"style":54},[480],{"type":20,"value":481},"    encoding: utf8\n",{"type":15,"tag":41,"props":483,"children":485},{"class":43,"line":484},20,[486],{"type":15,"tag":41,"props":487,"children":488},{"style":54},[489],{"type":20,"value":490},"  output_file:\n",{"type":15,"tag":41,"props":492,"children":494},{"class":43,"line":493},21,[495,499],{"type":15,"tag":41,"props":496,"children":497},{"style":326},[498],{"type":20,"value":329},{"type":15,"tag":41,"props":500,"children":501},{"style":54},[502],{"type":20,"value":398},{"type":15,"tag":41,"props":504,"children":506},{"class":43,"line":505},22,[507,511],{"type":15,"tag":41,"props":508,"children":509},{"style":54},[510],{"type":20,"value":343},{"type":15,"tag":41,"props":512,"children":513},{"style":215},[514],{"type":20,"value":515},"NOTSET\n",{"type":15,"tag":41,"props":517,"children":519},{"class":43,"line":518},23,[520],{"type":15,"tag":41,"props":521,"children":522},{"style":54},[523],{"type":20,"value":357},{"type":15,"tag":41,"props":525,"children":527},{"class":43,"line":526},24,[528,532,536],{"type":15,"tag":41,"props":529,"children":530},{"style":54},[531],{"type":20,"value":428},{"type":15,"tag":41,"props":533,"children":534},{"style":48},[535],{"type":20,"value":433},{"type":15,"tag":41,"props":537,"children":538},{"style":54},[539],{"type":20,"value":540},"output.log\n",{"type":15,"tag":41,"props":542,"children":544},{"class":43,"line":543},25,[545],{"type":15,"tag":41,"props":546,"children":547},{"style":455},[548],{"type":20,"value":549},"    # maxBytes: 10485760  # 10 MB\n",{"type":15,"tag":41,"props":551,"children":553},{"class":43,"line":552},26,[554,558,563],{"type":15,"tag":41,"props":555,"children":556},{"style":54},[557],{"type":20,"value":467},{"type":15,"tag":41,"props":559,"children":560},{"style":215},[561],{"type":20,"value":562},"20",{"type":15,"tag":41,"props":564,"children":565},{"style":455},[566],{"type":20,"value":567},"  # Rotates this many times when maxBytes is reached\n",{"type":15,"tag":41,"props":569,"children":571},{"class":43,"line":570},27,[572],{"type":15,"tag":41,"props":573,"children":574},{"style":54},[575],{"type":20,"value":481},{"type":15,"tag":41,"props":577,"children":579},{"class":43,"line":578},28,[580],{"type":15,"tag":41,"props":581,"children":582},{"style":54},[583],{"type":20,"value":584},"loggers:\n",{"type":15,"tag":41,"props":586,"children":588},{"class":43,"line":587},29,[589,594],{"type":15,"tag":41,"props":590,"children":591},{"style":54},[592],{"type":20,"value":593},"  __main__:  ",{"type":15,"tag":41,"props":595,"children":596},{"style":455},[597],{"type":20,"value":598},"# Main module, the one you execute\n",{"type":15,"tag":41,"props":600,"children":602},{"class":43,"line":601},30,[603,607],{"type":15,"tag":41,"props":604,"children":605},{"style":54},[606],{"type":20,"value":343},{"type":15,"tag":41,"props":608,"children":609},{"style":215},[610],{"type":20,"value":348},{"type":15,"tag":41,"props":612,"children":614},{"class":43,"line":613},31,[615],{"type":15,"tag":41,"props":616,"children":617},{"style":455},[618],{"type":20,"value":619},"    # handlers: [console]\n",{"type":15,"tag":41,"props":621,"children":623},{"class":43,"line":622},32,[624],{"type":15,"tag":41,"props":625,"children":626},{"style":54},[627],{"type":20,"value":628},"    handlers: [error_file, output_file]\n",{"type":15,"tag":41,"props":630,"children":632},{"class":43,"line":631},33,[633,638],{"type":15,"tag":41,"props":634,"children":635},{"style":54},[636],{"type":20,"value":637},"    propagate: no  ",{"type":15,"tag":41,"props":639,"children":640},{"style":455},[641],{"type":20,"value":642},"# Do not propagate to `root` level.\n",{"type":15,"tag":41,"props":644,"children":646},{"class":43,"line":645},34,[647,652],{"type":15,"tag":41,"props":648,"children":649},{"style":54},[650],{"type":20,"value":651},"  models:  ",{"type":15,"tag":41,"props":653,"children":654},{"style":455},[655],{"type":20,"value":656},"# Set up logger for `models` module - change this to your module name\n",{"type":15,"tag":41,"props":658,"children":660},{"class":43,"line":659},35,[661,665],{"type":15,"tag":41,"props":662,"children":663},{"style":54},[664],{"type":20,"value":343},{"type":15,"tag":41,"props":666,"children":667},{"style":215},[668],{"type":20,"value":348},{"type":15,"tag":41,"props":670,"children":672},{"class":43,"line":671},36,[673],{"type":15,"tag":41,"props":674,"children":675},{"style":54},[676],{"type":20,"value":677},"    propagate: no\n",{"type":15,"tag":41,"props":679,"children":681},{"class":43,"line":680},37,[682,687],{"type":15,"tag":41,"props":683,"children":684},{"style":54},[685],{"type":20,"value":686},"  features:  ",{"type":15,"tag":41,"props":688,"children":689},{"style":455},[690],{"type":20,"value":691},"# `features` module - change this to your current module name\n",{"type":15,"tag":41,"props":693,"children":695},{"class":43,"line":694},38,[696,700],{"type":15,"tag":41,"props":697,"children":698},{"style":54},[699],{"type":20,"value":343},{"type":15,"tag":41,"props":701,"children":702},{"style":215},[703],{"type":20,"value":348},{"type":15,"tag":41,"props":705,"children":707},{"class":43,"line":706},39,[708],{"type":15,"tag":41,"props":709,"children":710},{"style":54},[711],{"type":20,"value":628},{"type":15,"tag":41,"props":713,"children":715},{"class":43,"line":714},40,[716],{"type":15,"tag":41,"props":717,"children":718},{"style":54},[719],{"type":20,"value":677},{"type":15,"tag":41,"props":721,"children":723},{"class":43,"line":722},41,[724],{"type":15,"tag":41,"props":725,"children":726},{"style":54},[727],{"type":20,"value":728},"root:\n",{"type":15,"tag":41,"props":730,"children":732},{"class":43,"line":731},42,[733,738],{"type":15,"tag":41,"props":734,"children":735},{"style":54},[736],{"type":20,"value":737},"  level: ",{"type":15,"tag":41,"props":739,"children":740},{"style":215},[741],{"type":20,"value":348},{"type":15,"tag":41,"props":743,"children":745},{"class":43,"line":744},43,[746],{"type":15,"tag":41,"props":747,"children":748},{"style":54},[749],{"type":20,"value":750},"  handlers: [console, error_file, output_file]\n",{"type":15,"tag":16,"props":752,"children":753},{},[754,756,762],{"type":20,"value":755},"Note that ",{"type":15,"tag":23,"props":757,"children":759},{"className":758},[],[760],{"type":20,"value":761},"fileHandlers.handlers.MakedirsRotatingFileHandler",{"type":20,"value":763}," is a custom file handler that automatically creates the parent directories of the log file, if needed.",{"type":15,"tag":16,"props":765,"children":766},{},[767],{"type":20,"value":768},"To load a logging config file:",{"type":15,"tag":32,"props":770,"children":772},{"className":34,"code":771,"language":10,"meta":7,"style":7},"import yaml\nfrom yaml import Loader\nimport logging\n\ndef get_logging_config(path_conf=\"config/logging_conf.yaml\"):\n    # Load logging configs\n    with open(path_conf) as fin:\n        loggingConf = yaml.load(fin, Loader)\n    return loggingConf\n\n# Apply configs:\n\nloggingConf = get_logging_config()\nlogging.config.dictConfig(loggingConf)\n",[773],{"type":15,"tag":23,"props":774,"children":775},{"__ignoreMap":7},[776,788,810,821,828,867,875,903,920,933,940,948,955,972],{"type":15,"tag":41,"props":777,"children":778},{"class":43,"line":44},[779,783],{"type":15,"tag":41,"props":780,"children":781},{"style":48},[782],{"type":20,"value":51},{"type":15,"tag":41,"props":784,"children":785},{"style":54},[786],{"type":20,"value":787}," yaml\n",{"type":15,"tag":41,"props":789,"children":790},{"class":43,"line":60},[791,796,801,805],{"type":15,"tag":41,"props":792,"children":793},{"style":48},[794],{"type":20,"value":795},"from",{"type":15,"tag":41,"props":797,"children":798},{"style":54},[799],{"type":20,"value":800}," yaml ",{"type":15,"tag":41,"props":802,"children":803},{"style":48},[804],{"type":20,"value":51},{"type":15,"tag":41,"props":806,"children":807},{"style":54},[808],{"type":20,"value":809}," Loader\n",{"type":15,"tag":41,"props":811,"children":812},{"class":43,"line":70},[813,817],{"type":15,"tag":41,"props":814,"children":815},{"style":48},[816],{"type":20,"value":51},{"type":15,"tag":41,"props":818,"children":819},{"style":54},[820],{"type":20,"value":57},{"type":15,"tag":41,"props":822,"children":823},{"class":43,"line":237},[824],{"type":15,"tag":41,"props":825,"children":826},{"emptyLinePlaceholder":64},[827],{"type":20,"value":67},{"type":15,"tag":41,"props":829,"children":830},{"class":43,"line":296},[831,836,842,847,853,857,862],{"type":15,"tag":41,"props":832,"children":833},{"style":326},[834],{"type":20,"value":835},"def",{"type":15,"tag":41,"props":837,"children":839},{"style":838},"--shiki-default:#6F42C1;--shiki-dark-mode:#A6E22E;--shiki-sky-dark-mode:#A6E22E;--shiki-light-mode:#6F42C1;--shiki-blue-mode:#A6E22E",[840],{"type":20,"value":841}," get_logging_config",{"type":15,"tag":41,"props":843,"children":844},{"style":54},[845],{"type":20,"value":846},"(",{"type":15,"tag":41,"props":848,"children":850},{"style":849},"--shiki-default:#24292E;--shiki-dark-mode:#FD971F;--shiki-sky-dark-mode:#FD971F;--shiki-light-mode:#24292E;--shiki-blue-mode:#FD971F;--shiki-default-font-style:inherit;--shiki-dark-mode-font-style:italic;--shiki-sky-dark-mode-font-style:italic;--shiki-light-mode-font-style:inherit;--shiki-blue-mode-font-style:italic",[851],{"type":20,"value":852},"path_conf",{"type":15,"tag":41,"props":854,"children":855},{"style":48},[856],{"type":20,"value":81},{"type":15,"tag":41,"props":858,"children":859},{"style":252},[860],{"type":20,"value":861},"\"config/logging_conf.yaml\"",{"type":15,"tag":41,"props":863,"children":864},{"style":54},[865],{"type":20,"value":866},"):\n",{"type":15,"tag":41,"props":868,"children":869},{"class":43,"line":304},[870],{"type":15,"tag":41,"props":871,"children":872},{"style":455},[873],{"type":20,"value":874},"    # Load logging configs\n",{"type":15,"tag":41,"props":876,"children":877},{"class":43,"line":313},[878,883,888,893,898],{"type":15,"tag":41,"props":879,"children":880},{"style":48},[881],{"type":20,"value":882},"    with",{"type":15,"tag":41,"props":884,"children":885},{"style":241},[886],{"type":20,"value":887}," open",{"type":15,"tag":41,"props":889,"children":890},{"style":54},[891],{"type":20,"value":892},"(path_conf) ",{"type":15,"tag":41,"props":894,"children":895},{"style":48},[896],{"type":20,"value":897},"as",{"type":15,"tag":41,"props":899,"children":900},{"style":54},[901],{"type":20,"value":902}," fin:\n",{"type":15,"tag":41,"props":904,"children":905},{"class":43,"line":322},[906,911,915],{"type":15,"tag":41,"props":907,"children":908},{"style":54},[909],{"type":20,"value":910},"        loggingConf ",{"type":15,"tag":41,"props":912,"children":913},{"style":48},[914],{"type":20,"value":81},{"type":15,"tag":41,"props":916,"children":917},{"style":54},[918],{"type":20,"value":919}," yaml.load(fin, Loader)\n",{"type":15,"tag":41,"props":921,"children":922},{"class":43,"line":337},[923,928],{"type":15,"tag":41,"props":924,"children":925},{"style":48},[926],{"type":20,"value":927},"    return",{"type":15,"tag":41,"props":929,"children":930},{"style":54},[931],{"type":20,"value":932}," loggingConf\n",{"type":15,"tag":41,"props":934,"children":935},{"class":43,"line":351},[936],{"type":15,"tag":41,"props":937,"children":938},{"emptyLinePlaceholder":64},[939],{"type":20,"value":67},{"type":15,"tag":41,"props":941,"children":942},{"class":43,"line":360},[943],{"type":15,"tag":41,"props":944,"children":945},{"style":455},[946],{"type":20,"value":947},"# Apply configs:\n",{"type":15,"tag":41,"props":949,"children":950},{"class":43,"line":379},[951],{"type":15,"tag":41,"props":952,"children":953},{"emptyLinePlaceholder":64},[954],{"type":20,"value":67},{"type":15,"tag":41,"props":956,"children":957},{"class":43,"line":388},[958,963,967],{"type":15,"tag":41,"props":959,"children":960},{"style":54},[961],{"type":20,"value":962},"loggingConf ",{"type":15,"tag":41,"props":964,"children":965},{"style":48},[966],{"type":20,"value":81},{"type":15,"tag":41,"props":968,"children":969},{"style":54},[970],{"type":20,"value":971}," get_logging_config()\n",{"type":15,"tag":41,"props":973,"children":974},{"class":43,"line":401},[975],{"type":15,"tag":41,"props":976,"children":977},{"style":54},[978],{"type":20,"value":979},"logging.config.dictConfig(loggingConf)\n",{"type":15,"tag":981,"props":982,"children":983},"style",{},[984],{"type":20,"value":985},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html.dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html .sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html.sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html .light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html.light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html .blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}html.blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}",{"title":7,"searchDepth":60,"depth":60,"links":987},[],"markdown","content:tutorials:python-logging.md","content","tutorials/python-logging.md","tutorials/python-logging","md",1793934184838]