-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kash
committed
Apr 11, 2023
1 parent
7357d6b
commit e908948
Showing
10 changed files
with
304 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import configparser | ||
|
||
config = configparser.ConfigParser() | ||
config.read('Config/logger.ini') | ||
config.read("Config/logger.ini") | ||
|
||
# check if the required sections are present | ||
if 'loggers' not in config.sections() or 'handlers' not in config.sections(): | ||
raise ValueError('Missing required section in config.ini') | ||
if "loggers" not in config.sections() or "handlers" not in config.sections(): | ||
raise ValueError("Missing required section in config.ini") | ||
|
||
if 'keys' not in config['loggers'] or 'suspicious' not in config['loggers']: | ||
raise ValueError('Missing required key in loggers section in config.ini') | ||
if "keys" not in config["loggers"] or "suspicious" not in config["loggers"]: | ||
raise ValueError("Missing required key in loggers section in config.ini") | ||
|
||
# check if the required keys are present in the 'handlers' section | ||
if 'keys' not in config['handlers'] or 'console' not in config['handlers']['keys']: | ||
raise ValueError('Missing required key in handlers section in config.ini') | ||
if "keys" not in config["handlers"] or "console" not in config["handlers"]["keys"]: | ||
raise ValueError("Missing required key in handlers section in config.ini") | ||
|
||
# check if the values of the keys are in the expected format | ||
if not isinstance(config.getint('handlers', 'console.level'), int): | ||
raise ValueError('Invalid value for console.level in config.ini') | ||
|
||
if not isinstance(config.getint('loggers', 'keys.suspicious.level'), int): | ||
raise ValueError('Invalid value for keys.suspicious.level in config.ini') | ||
if not isinstance(config.getint("handlers", "console.level"), int): | ||
raise ValueError("Invalid value for console.level in config.ini") | ||
|
||
if not isinstance(config.getint("loggers", "keys.suspicious.level"), int): | ||
raise ValueError("Invalid value for keys.suspicious.level in config.ini") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.