Skip to content

Add logger to run script #83

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

Merged
merged 3 commits into from
Feb 6, 2021
Merged

Conversation

coni2k
Copy link
Contributor

@coni2k coni2k commented Feb 6, 2021

I tried to add "logger" to run script before but somehow I couldn't make it work. Now it turned out to be a very simple one 🤷‍♂️

I'm just not sure about moving "initialize_logging_handlers" function to a generic place.

It's very similar to the one in "generate" script:

run

def initialize_logging_handlers():
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('').handlers.clear()

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    logging.getLogger('').addHandler(console)

generate

def initialize_logging_handlers(output_dir):
    log_filename = os.path.join(output_dir, 'output.log')
    logging.basicConfig(filename=log_filename, filemode='w', level=logging.INFO)

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    logging.getLogger('').addHandler(console)

@inferno-chromium inferno-chromium merged commit 512b3d0 into ossf:main Feb 6, 2021
@coni2k coni2k deleted the add-logger-run branch February 7, 2021 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants