Skip to content
Snippets Groups Projects
Commit 5ebfb82c authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #1 - general setup

parent 3c375148
Branches
No related tags found
No related merge requests found
/dist/
/MANIFEST
/build/
/PythonLibs.egg-info/
MIT License
Copyright (c) [year] [fullname]
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.
\ No newline at end of file
import logging
import sys
class DefaultLogger:
DEFAULT_LOG_FORMAT = '[%(levelname)-7s] - %(asctime)s - %(module)s.%(funcName)s:%(lineno)d: %(message)s'
DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
@classmethod
def create_logger(cls, appName: str, logLevel=logging.DEBUG, logFormat=None, dateFormat=None) -> logging.Logger:
logger = logging.getLogger(appName)
return cls.configure_logger(logger, logLevel, logFormat, dateFormat)
@classmethod
def configure_logger(cls, logger: logging.Logger,
logLevel=logging.DEBUG,
logFormat=None,
dateFormat=None) -> logging.Logger:
logFormatter = cls.__create_formatter(logFormat, dateFormat)
logger.setLevel(logLevel)
outHandler = logging.StreamHandler(sys.stdout)
outHandler.setFormatter(logFormatter)
outHandler.setLevel(logging.DEBUG)
outHandler.addFilter(lambda record: record.levelno <= logging.INFO)
logger.addHandler(outHandler)
errHandler = logging.StreamHandler(sys.stderr)
errHandler.setFormatter(logFormatter)
errHandler.setLevel(logging.WARNING)
logger.addHandler(errHandler)
return logger
@classmethod
def __create_formatter(cls, logFormat=None, dateFormat=None) -> logging.Formatter:
if logFormat is None:
logFormat = cls.DEFAULT_LOG_FORMAT
if dateFormat is None:
dateFormat = cls.DEFAULT_DATE_FORMAT
return logging.Formatter(fmt=logFormat, datefmt=dateFormat)
from PythonLibs.DefaultLogger import DefaultLogger
# PythonLibs
Useful python classes.
\ No newline at end of file
[metadata]
description-file = README.md
\ No newline at end of file
setup.py 0 → 100644
from setuptools import setup
setup(
name='PythonLibs',
packages=['PythonLibs'],
version='1.0.0',
license='MIT',
description='Useful python classes',
author='TheCodeLabs',
author_email='spam@thecodelabs.de',
url='https://thecodelabs.de/TheCodeLabs/PythonLibs',
keywords=[],
install_requires=[
],
setup_requires=[
'wheel'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7'
]
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment