mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-11 00:23:15 +03:00
Added Logging and Error Handling
This commit is contained in:
parent
23dda1022d
commit
67518e7895
26
sqlmapapi.py
Executable file → Normal file
26
sqlmapapi.py
Executable file → Normal file
|
@ -6,15 +6,24 @@ See the file 'LICENSE' for copying permission
|
|||
"""
|
||||
|
||||
import sys
|
||||
import logging
|
||||
import os
|
||||
import warnings
|
||||
|
||||
# Error management and logging setup
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(levelname)s - %(message)s', # Log format
|
||||
level=logging.DEBUG, # Set log level to DEBUG
|
||||
handlers=[logging.StreamHandler()] # Print logs to console
|
||||
)
|
||||
|
||||
# Logger object
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
sys.dont_write_bytecode = True
|
||||
|
||||
__import__("lib.utils.versioncheck") # this has to be the first non-standard import
|
||||
|
||||
import logging
|
||||
import os
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings(action="ignore", category=UserWarning)
|
||||
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
|
||||
|
||||
|
@ -83,7 +92,7 @@ def main():
|
|||
"""
|
||||
REST-JSON API main function
|
||||
"""
|
||||
|
||||
try:
|
||||
dirtyPatches()
|
||||
resolveCrossReferences()
|
||||
|
||||
|
@ -114,5 +123,12 @@ def main():
|
|||
else:
|
||||
apiparser.print_help()
|
||||
|
||||
except Exception as e:
|
||||
logger.critical("An error occurred while executing the main function: %s", e, exc_info=True)
|
||||
raise # Stop the program after the error
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
logger.critical("An unexpected error occurred while running the program: %s", e, exc_info=True)
|
||||
|
|
Loading…
Reference in New Issue
Block a user