commit
3328218430
13
Pipfile
Normal file
13
Pipfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[[source]]
|
||||||
|
name = "pypi"
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
pytz = "*"
|
||||||
|
colorlog = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.7"
|
37
Pipfile.lock
generated
Normal file
37
Pipfile.lock
generated
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"_meta": {
|
||||||
|
"hash": {
|
||||||
|
"sha256": "c3b3b5ada235f990ea1b0bb44dae216d93e828643578819ad98876264acab566"
|
||||||
|
},
|
||||||
|
"pipfile-spec": 6,
|
||||||
|
"requires": {
|
||||||
|
"python_version": "3.7"
|
||||||
|
},
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"name": "pypi",
|
||||||
|
"url": "https://pypi.org/simple",
|
||||||
|
"verify_ssl": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"colorlog": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:3cf31b25cbc8f86ec01fef582ef3b840950dea414084ed19ab922c8b493f9b42",
|
||||||
|
"sha256:450f52ea2a2b6ebb308f034ea9a9b15cea51e65650593dca1da3eb792e4e4981"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==4.0.2"
|
||||||
|
},
|
||||||
|
"pytz": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:26c0b32e437e54a18161324a2fca3c4b9846b74a8dccddd843113109e1116b32",
|
||||||
|
"sha256:c894d57500a4cd2d5c71114aaab77dbab5eabd9022308ce5ac9bb93a60a6f0c7"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==2019.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"develop": {}
|
||||||
|
}
|
@ -8,4 +8,4 @@ log.error("something went wrong.")
|
|||||||
|
|
||||||
log.die("bailing out") # exits
|
log.die("bailing out") # exits
|
||||||
|
|
||||||
print "no soup for you."
|
print("no soup for you.")
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
#234567891123456789212345678931234567894123456789512345678961234567897123456789
|
#234567891123456789212345678931234567894123456789512345678961234567897123456789
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
from pytz import reference
|
||||||
|
import time
|
||||||
import colorlog
|
import colorlog
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -16,19 +20,34 @@ ch = logging.StreamHandler() # defaults to sys.stderr
|
|||||||
|
|
||||||
log.addHandler(ch)
|
log.addHandler(ch)
|
||||||
|
|
||||||
formatstr = '%(asctime)s [%(levelname)-.4s] %(message)s'
|
|
||||||
|
formatstr = '%(asctime)s.%(msecs)03d [%(levelname)-.4s] %(message)s'
|
||||||
|
datefmt = '%Y-%m-%dT%H:%M:%S'
|
||||||
|
|
||||||
|
localtime = reference.LocalTimezone()
|
||||||
|
if localtime.tzname(datetime.datetime.now()) == 'UTC':
|
||||||
|
# UTC time, just append Z
|
||||||
|
formatstr = '%(asctime)s.%(msecs)03dZ [%(levelname)-.4s] %(message)s'
|
||||||
|
else:
|
||||||
|
# not UTC, append offset of local system time
|
||||||
|
minute = (time.localtime().tm_gmtoff / 60) % 60
|
||||||
|
hour = ((time.localtime().tm_gmtoff / 60) - minute) / 60
|
||||||
|
utcoffset = "%.2d%.2d" %(hour, minute)
|
||||||
|
if utcoffset[0] != '-':
|
||||||
|
utcoffset = '+' + utcoffset
|
||||||
|
formatstr = '%(asctime)s.%(msecs)03d' + utcoffset + ' [%(levelname)-.4s] %(message)s'
|
||||||
|
|
||||||
colorFormatter = colorlog.ColoredFormatter(
|
colorFormatter = colorlog.ColoredFormatter(
|
||||||
'%(log_color)s' + formatstr
|
fmt='%(log_color)s' + formatstr, datefmt=datefmt
|
||||||
)
|
)
|
||||||
|
|
||||||
formatter = logging.Formatter(
|
formatter = logging.Formatter(
|
||||||
formatstr
|
fmt=formatstr,
|
||||||
|
datefmt=datefmt
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
log.notice = log.info
|
log.notice = log.info
|
||||||
|
|
||||||
|
|
||||||
if sys.stdout.isatty():
|
if sys.stdout.isatty():
|
||||||
ch.setFormatter(colorFormatter)
|
ch.setFormatter(colorFormatter)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user