How to check if debug is true and can I use it for my own code?

This question is an exact duplicate of:

  • Disable Debug Log Programmatically

    1 answer

Solutions Collecting From Web of "How to check if debug is true and can I use it for my own code?"