sankalpjonn / timeloop

An elegant periodic task executor
MIT License
245 stars 49 forks source link

Double output with coloredlogs and logging #5

Open jjanis opened 5 years ago

jjanis commented 5 years ago

Your code causes double output when used in project where I define my own loggers with logging.DEBUG level.

#!/usr/bin/env python3

import logging
import coloredlogs
from datetime import timedelta
from timeloop import Timeloop

logging.basicConfig(level=logging.DEBUG)
coloredlogs.install(level=logging.DEBUG)
logger = logging.getLogger(__name__)

looper = Timeloop()

@looper.job(interval=timedelta(seconds=5))
def work():
    pass

looper.start(block=True)
sankalpjonn commented 5 years ago

Hello Jānis,

Thanks for bringing this to my attention, I will fix it when i find some time. In case you have already found a fix for this, i would highly appreciate it if you can create a pull request for it.

Thanks again. Regards, Sankalp

On Tue, Apr 16, 2019, 15:38 Jānis Judvaitis notifications@github.com wrote:

Your code causes double output when used in project where I define my own loggers with logging.DEBUG level.

!/usr/bin/env python3

import logging import coloredlogs from datetime import timedelta from timeloop import Timeloop

logging.basicConfig(level=logging.DEBUG) coloredlogs.install(level=logging.DEBUG) logger = logging.getLogger(name)

looper = Timeloop()

@looper.job(interval=timedelta(seconds=5)) def work(): pass

looper.start(block=True)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sankalpjonn/timeloop/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/AQDeazB_9VUFRozSnnu4hij9mer5ELB9ks5vhaEZgaJpZM4cx2x_ .

lockieRichter commented 4 years ago

Having this same issue, has this been resolved?

KoenDierckx commented 3 years ago

I solved it this way

# Timeloop has a default logging handler, remove it, so we only use our own handlers (avoids duplicate logs) logging.getLogger('timeloop').handlers.clear()