Check existance of and create logfile at startup
This commit is contained in:
		
							parent
							
								
									79ce720ea9
								
							
						
					
					
						commit
						7f3b643139
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
from sys import exit
 | 
					from sys import exit
 | 
				
			||||||
from os import chdir, getenv, system
 | 
					from os import chdir, getenv, system, path
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
import tomllib
 | 
					import tomllib
 | 
				
			||||||
from datetime import datetime, time
 | 
					from datetime import datetime, time
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,8 @@ class _ConfigLib:
 | 
				
			||||||
        chdir("/var/log/wallman/")
 | 
					        chdir("/var/log/wallman/")
 | 
				
			||||||
        numeric_level: int = getattr(logging, self.config_log_level, logging.INFO)
 | 
					        numeric_level: int = getattr(logging, self.config_log_level, logging.INFO)
 | 
				
			||||||
        logger.setLevel(numeric_level)
 | 
					        logger.setLevel(numeric_level)
 | 
				
			||||||
 | 
					        if not path.exists("wallman.log"):
 | 
				
			||||||
 | 
					            system("touch wallman.log")
 | 
				
			||||||
        logging.basicConfig(filename="wallman.log", encoding="utf-8", level=numeric_level)
 | 
					        logging.basicConfig(filename="wallman.log", encoding="utf-8", level=numeric_level)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO: Make this all just work inside the try/except block, there is no need for get()
 | 
					    # TODO: Make this all just work inside the try/except block, there is no need for get()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue