PK OXi i logsensei/__init__.py"""Personal Formatting on Loguru"""
__version__ = "0.0.1"
__author__ = "Aditya Kelvianto Sidharta"
import datetime
import logging
import os
import sys
from loguru import logger as loguru_logger
def _get_datetime():
return datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
class Logger:
"""
Setting up logger for the project. The log will be logged within the file as well
logger.setup_logger(script_name) must be called first before using the logger.
"""
def __init__(self):
self.name = None
self.datetime = None
self.level = None
self.format = None
self.logger = None
self.is_setup = False
def setup_logger(self, name, logger_file, level=logging.INFO):
self.name = name
self.datetime = _get_datetime()
self.level = level
self.format = "{time:YYYY-MM-DD HH:mm:ss} | {level: <8} |" \
" {name}:{function}:{line} - {message}"
self.logger = loguru_logger
self.logger.add(sys.stderr, format=self.format, level=self.level)
self.logger.add(
os.path.join(logger_file, "{}_{}.log".format(self.name, self.datetime)),
format=self.format,
level=self.level,
)
self.is_setup = True
def info(self, msg):
assert self.is_setup, "Please Setup the Logger First"
return self.logger.info(msg)
def debug(self, msg):
assert self.is_setup, "Please Setup the Logger First"
return self.logger.debug(msg)
def error(self, msg):
assert self.is_setup, "Please Setup the Logger First"
return self.logger.error(msg)
def warning(self, msg):
assert self.is_setup, "Please Setup the Logger First"
return self.logger.warning(msg)
logger = Logger()
PK O=%: : ! logsensei-0.0.1.dist-info/LICENSEMIT License
Copyright (c) 2019 Aditya Kelvianto Sidharta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
PK !HMuS a logsensei-0.0.1.dist-info/WHEELHM
K-*ϳR03rOK-J,/RH,szd&Y)r$[)T&UD" PK !Hx 3 " logsensei-0.0.1.dist-info/METADATAEPN0)mǜ@i[(?gRęW*V2Kp[ߘYgz5} K%TA"lŗT̓&sԠ:e4u(AB:Lٖ`tδEI~Uj(*
ȣ<Z9Ӝt ka߯$Gr˾[^iB߅ꁳPK !HL { logsensei-0.0.1.dist-info/RECORD}vC@ }3)8*+FC{nGcяE}LӺ4evTa 9tA P Nr>tF˜G=Ntݗ:&'. iY; T,o砑8ΗˬBgsq Z9T+ f9GҫAO v*PCu-gÄZ
`.uPK OXi i logsensei/__init__.pyPK O=%: : ! logsensei-0.0.1.dist-info/LICENSEPK !HMuS a logsensei-0.0.1.dist-info/WHEELPK !Hx 3 " logsensei-0.0.1.dist-info/METADATAPK !HL {
logsensei-0.0.1.dist-info/RECORDPK }