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

Fix LoggingHandler time conversion #304

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions logbook/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
:copyright: (c) 2010 by Armin Ronacher, Georg Brandl.
:license: BSD, see LICENSE for more details.
"""
import collections
import time
import logging
import sys
import warnings
from datetime import date, datetime
from datetime import datetime

import logbook
from logbook.helpers import u, string_types, iteritems, collections_abc

_epoch_ord = date(1970, 1, 1).toordinal()


def redirect_logging(set_root_logger_level=True):
"""Permanently redirects logging to the stdlib. This also
Expand Down Expand Up @@ -193,12 +191,7 @@ def convert_level(self, level):

def convert_time(self, dt):
"""Converts a datetime object into a timestamp."""
year, month, day, hour, minute, second = dt.utctimetuple()[:6]
days = date(year, month, 1).toordinal() - _epoch_ord + day - 1
hours = days * 24 + hour
minutes = hours * 60 + minute
seconds = minutes * 60 + second
return seconds
return time.mktime(dt.timetuple()) + dt.microsecond / 1E6

def convert_record(self, old_record):
"""Converts a record from logbook to logging."""
Expand Down