Skip to content

Commit

Permalink
fix date format (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
raffo0707 authored Feb 1, 2018
1 parent 38a555a commit f0f7644
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

setup(name='unipy_logger',
keywords='log, json, uniplaces',
version='0.1.5',
version='0.1.9',
description='enforce uniplaces log standards and respect uniplaces logging interface.',
url='https://github.com/uniplaces/unipy_logger',
author='Raffaello De Pieri',
author_email='[email protected]',
license='MIT',
packages=['unipy_logger'],
install_requires=['maya', 'logbook'],
install_requires=['logbook', 'strict_rfc3339'],
zip_safe=False)
11 changes: 5 additions & 6 deletions unipy_logger/uni_logger.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/python3

import time
import datetime
import strict_rfc3339
import os
import sys
import json
import logging

from logbook import Logger, StreamHandler


CRITICAL = "CRITICAL"
ERROR = "ERROR"
WARNING = "WARNING"
Expand Down Expand Up @@ -60,21 +59,21 @@ def json_formatter(self, record, handler):
"message": record.message,
"app-id": os.environ.get('APPID'),
"git-hash": os.environ.get('GITHASH'),
"time": datetime.datetime.now().time().strftime('%H:%M:%S.%f'),
"time": strict_rfc3339.now_to_rfc3339_utcoffset(integer=True),
"env": os.environ.get('ENV'),
"level_name": self.messageLevel,
"level": LOG_LEVELS[self.messageLevel]
}

return json.dumps({**defaultMessage, **self.context})

def addContextField(self, key, value):
def add_context_field(self, key, value):
""" Add a context field. """
self.context.update({key: value})

return self

def addContextFields(self, newFields):
def add_context_fields(self, newFields):
""" Add several fields. """
self.context.update(newFields)

Expand Down

0 comments on commit f0f7644

Please sign in to comment.