mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-04 13:13:34 +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 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
|
sys.dont_write_bytecode = True
|
||||||
|
|
||||||
__import__("lib.utils.versioncheck") # this has to be the first non-standard import
|
__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=UserWarning)
|
||||||
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
|
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
|
||||||
|
|
||||||
|
@ -83,7 +92,7 @@ def main():
|
||||||
"""
|
"""
|
||||||
REST-JSON API main function
|
REST-JSON API main function
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
dirtyPatches()
|
dirtyPatches()
|
||||||
resolveCrossReferences()
|
resolveCrossReferences()
|
||||||
|
|
||||||
|
@ -114,5 +123,12 @@ def main():
|
||||||
else:
|
else:
|
||||||
apiparser.print_help()
|
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__":
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
main()
|
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