Skip to content

Commit

Permalink
Adds file and line number info to debug statements
Browse files Browse the repository at this point in the history
e.g.,

(debug) benchpark::72 Hello, world!
  • Loading branch information
rountree-alt committed May 8, 2024
1 parent 5db2c96 commit 2cb9dff
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bin/benchpark
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,29 @@ import shutil
import subprocess
import sys
import yaml
from inspect import currentframe, getframeinfo

DEBUG = False
DEBUG = True

__version__ = "0.1.0"


def get_linenumber():
cf = currentframe()
return cf.f_back.f_back.f_lineno


def get_filename():
cf = currentframe()
return os.path.basename(getframeinfo(cf.f_back).filename)


def debug_print(message):
if DEBUG:
print("(debug) " + str(message))
print(
"(debug) " + get_filename() + "::" + str(get_linenumber()) + " " + message,
file=sys.stderr,
)


def main():
Expand Down Expand Up @@ -62,6 +76,7 @@ def main():


def get_version():
debug_print("Hello, world!")
benchpark_version = __version__
return benchpark_version

Expand Down

0 comments on commit 2cb9dff

Please sign in to comment.