From c62f46980c391b9f1701356931eddf491821833f Mon Sep 17 00:00:00 2001 From: maldevel Date: Thu, 31 Dec 2015 11:33:31 +0200 Subject: [PATCH] logs save log files to logs dir, fixed log datetime --- geolocation/IpGeoLocation.py | 2 +- geolocation/IpGeoLocationLib.py | 2 +- geolocation/__init__.py | 2 +- ip2geolocation.py | 2 +- libraries/__init__.py | 2 +- logs/.gitignore | 2 ++ utilities/FileExporter.py | 2 +- utilities/Logger.py | 12 +++++++----- utilities/MyExceptions.py | 2 +- utilities/__init__.py | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 logs/.gitignore diff --git a/geolocation/IpGeoLocation.py b/geolocation/IpGeoLocation.py index 03e52d3..267e6be 100644 --- a/geolocation/IpGeoLocation.py +++ b/geolocation/IpGeoLocation.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/geolocation/IpGeoLocationLib.py b/geolocation/IpGeoLocationLib.py index 2e9044e..ce70537 100644 --- a/geolocation/IpGeoLocationLib.py +++ b/geolocation/IpGeoLocationLib.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/geolocation/__init__.py b/geolocation/__init__.py index 90688c4..2398184 100644 --- a/geolocation/__init__.py +++ b/geolocation/__init__.py @@ -1,7 +1,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/ip2geolocation.py b/ip2geolocation.py index dc2a876..7a0fe2d 100644 --- a/ip2geolocation.py +++ b/ip2geolocation.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libraries/__init__.py b/libraries/__init__.py index 90688c4..2398184 100644 --- a/libraries/__init__.py +++ b/libraries/__init__.py @@ -1,7 +1,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/utilities/FileExporter.py b/utilities/FileExporter.py index 4ba1edb..367daba 100644 --- a/utilities/FileExporter.py +++ b/utilities/FileExporter.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/utilities/Logger.py b/utilities/Logger.py index ac52870..63c97b3 100644 --- a/utilities/Logger.py +++ b/utilities/Logger.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,13 +22,15 @@ __author__ = 'maldevel' -from time import gmtime, strftime +from datetime import datetime +import os class Logger: @staticmethod def WriteLog(messagetype, message): - filename = '{}.log'.format(strftime("%Y%m%d", gmtime())) - with open(filename, 'a') as logFile: - logFile.write('[{}] {} - {}\n'.format(messagetype, strftime("%Y-%m-%d %H:%M:%S", gmtime()), message)) + filename = '{}.log'.format(datetime.strftime(datetime.now(), "%Y%m%d")) + path = os.path.join('.', 'logs', filename) + with open(path, 'a') as logFile: + logFile.write('[{}] {} - {}\n'.format(messagetype, datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M:%S"), message)) \ No newline at end of file diff --git a/utilities/MyExceptions.py b/utilities/MyExceptions.py index 20628a6..353c9de 100644 --- a/utilities/MyExceptions.py +++ b/utilities/MyExceptions.py @@ -4,7 +4,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/utilities/__init__.py b/utilities/__init__.py index 90688c4..2398184 100644 --- a/utilities/__init__.py +++ b/utilities/__init__.py @@ -1,7 +1,7 @@ """ IPGeoLocation - Retrieve IP Geolocation information Powered by http://ip-api.com - Copyright (C) 2015 @maldevel + Copyright (C) 2015-2016 @maldevel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by