Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Line support #16

Open
wearpants opened this issue Apr 2, 2013 · 1 comment
Open

Source Line support #16

wearpants opened this issue Apr 2, 2013 · 1 comment

Comments

@wearpants
Copy link
Owner

Add feature or option flag for reporting the source line & filename where the log message originated.

@wearpants wearpants modified the milestone: 0.6 Oct 20, 2017
@MatthewScholefield
Copy link

MatthewScholefield commented Nov 17, 2017

For reference, here's the code to do it (Python 3):

import inspect

# Stack:
# [0] - this function
# [1] - caller
# [2] - ...
stack = inspect.stack()

# Record:
# [0] - frame object
# [1] - filename
# [2] - line number
# [3] - function
# ...
record = stack[2]
mod = inspect.getmodule(record[0])
mod_name = mod.__name__ if mod else ''
name = mod_name + ':' + record[3] + ':' + str(record[2])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants