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

Please improve logging formatter with time #447

Closed
MarcSkovMadsen opened this issue Oct 17, 2019 · 2 comments
Closed

Please improve logging formatter with time #447

MarcSkovMadsen opened this issue Oct 17, 2019 · 2 comments
Assignees
Labels
type:enhancement Requests for feature enhancements or new features

Comments

@MarcSkovMadsen
Copy link

MarcSkovMadsen commented Oct 17, 2019

Summary

In order to be able to trace errors using the log it would be really helpfull to get more information for like for example time.

Steps

If I set the logLevel = "debug" I get logging output. But it's difficult to track down issues over a longer period of time when there is no time information.

image

Expected

I would expect something like

image

Hack

For now you can insert

@st.cache
def set_logging_format() -> bool:
    loggers = [
        name for name in logging.root.manager.loggerDict if name.startswith("streamlit")
    ]
    formatter = logging.Formatter("%(asctime)s %(name)s: %(message)s")
    for name in loggers:
        logger = logging.getLogger(name)
        for ch in logger.handlers:
            ch.setFormatter(formatter)
    return True


set_logging_format()

in your app.py file. But it's looking a bit like a hack?

Feature Request

I would like to be able to either

  • run my own configuration script (including the above) on server start up

or

  • set a configuration setting in the config.toml file like
loggingFormat="%(asctime)s %(name)s: %(message)s"
@MarcSkovMadsen MarcSkovMadsen added the type:enhancement Requests for feature enhancements or new features label Oct 17, 2019
@MarcSkovMadsen MarcSkovMadsen changed the title Improved logging when logLevel = "debug" Please improve logging formatter with time Oct 17, 2019
@bukosabino
Copy link

Hi @MarcSkovMadsen ,

Your hack is not working in 0.52.0 version, right?

Any solution to use time info when we use logging?

Best,
Dario

@drorata
Copy link

drorata commented Feb 26, 2020

I got to this issue as I fail to define a logger with a customized format. It seems like streamlit hijacks loggers. Is it related? Can someone point me how to add loggers for my app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

No branches or pull requests

5 participants