Metadata-Version: 2.1
Name: lib-log-utils
Version: 0.1.2
Summary: colored log messages and banners from commandline and python
Home-page: https://github.com/bitranox/lib_log_utils
Author: Robert Nowotny
Author-email: bitranox@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6.0
Description-Content-Type: text/x-rst
Requires-Dist: click
Requires-Dist: coloredlogs
Requires-Dist: lib-parameter
Requires-Dist: lib-platform
Requires-Dist: lib-programname

lib_log_utils
=============

|travis_build| |license| |jupyter| |pypi|

|codecov| |better_code| |cc_maintain| |cc_issues| |cc_coverage| |snyk|


.. |travis_build| image:: https://img.shields.io/travis/bitranox/lib_log_utils/master.svg
   :target: https://travis-ci.org/bitranox/lib_log_utils

.. |license| image:: https://img.shields.io/github/license/webcomics/pywine.svg
   :target: http://en.wikipedia.org/wiki/MIT_License

.. |jupyter| image:: https://mybinder.org/badge_logo.svg
 :target: https://mybinder.org/v2/gh/bitranox/lib_log_utils/master?filepath=lib_log_utils.ipynb

.. for the pypi status link note the dashes, not the underscore !
.. |pypi| image:: https://img.shields.io/pypi/status/lib-log-utils?label=PyPI%20Package
   :target: https://badge.fury.io/py/lib_log_utils

.. |codecov| image:: https://img.shields.io/codecov/c/github/bitranox/lib_log_utils
   :target: https://codecov.io/gh/bitranox/lib_log_utils

.. |better_code| image:: https://bettercodehub.com/edge/badge/bitranox/lib_log_utils?branch=master
   :target: https://bettercodehub.com/results/bitranox/lib_log_utils

.. |cc_maintain| image:: https://img.shields.io/codeclimate/maintainability-percentage/bitranox/lib_log_utils?label=CC%20maintainability
   :target: https://codeclimate.com/github/bitranox/lib_log_utils/maintainability
   :alt: Maintainability

.. |cc_issues| image:: https://img.shields.io/codeclimate/issues/bitranox/lib_log_utils?label=CC%20issues
   :target: https://codeclimate.com/github/bitranox/lib_log_utils/maintainability
   :alt: Maintainability

.. |cc_coverage| image:: https://img.shields.io/codeclimate/coverage/bitranox/lib_log_utils?label=CC%20coverage
   :target: https://codeclimate.com/github/bitranox/lib_log_utils/test_coverage
   :alt: Code Coverage

.. |snyk| image:: https://img.shields.io/snyk/vulnerabilities/github/bitranox/lib_log_utils
   :target: https://snyk.io/test/github/bitranox/lib_log_utils

this library makes it easy to log colored messages from python and from the commandline. Text Wrapping is supported.

----

automated tests, Travis Matrix, Documentation, Badges, etc. are managed with `PizzaCutter <https://github
.com/bitranox/PizzaCutter>`_ (cookiecutter on steroids)

Python version required: 3.6.0 or newer

tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3

`good code coverage <https://codecov.io/gh/bitranox/lib_log_utils>`_, codestyle checking ,mypy static type checking ,tested under `Linux, macOS, Windows <https://travis-ci.org/bitranox/lib_log_utils>`_, automatic daily builds and monitoring

----

- `Try it Online`_
- `Installation and Upgrade`_
- `Usage`_
- `Usage from Commandline`_
- `Requirements`_
- `Acknowledgements`_
- `Contribute`_
- `Report Issues <https://github.com/bitranox/lib_log_utils/blob/master/ISSUE_TEMPLATE.md>`_
- `Pull Request <https://github.com/bitranox/lib_log_utils/blob/master/PULL_REQUEST_TEMPLATE.md>`_
- `Code of Conduct <https://github.com/bitranox/lib_log_utils/blob/master/CODE_OF_CONDUCT.md>`_
- `License`_
- `Changelog`_

----

Try it Online
-------------

You might try it right away in Jupyter Notebook by using the "launch binder" badge, or click `here <https://mybinder.org/v2/gh/{{rst_include.
repository_slug}}/master?filepath=lib_log_utils.ipynb>`_

Installation and Upgrade
------------------------

- Before You start, its highly recommended to update pip and setup tools:


.. code-block:: bash

    python -m pip --upgrade pip
    python -m pip --upgrade setuptools
    python -m pip --upgrade wheel

- to install the latest release from PyPi via pip (recommended):

.. code-block:: bash

    # install latest release from PyPi
    python -m pip install --upgrade lib_log_utils

    # test latest release from PyPi without installing (can be skipped)
    python -m pip install lib_log_utils --install-option test

- to install the latest development version from github via pip:


.. code-block:: bash

    # normal install
    python -m pip install --upgrade git+https://github.com/bitranox/lib_log_utils.git

    # to test without installing (can be skipped)
    python -m pip install git+https://github.com/bitranox/lib_log_utils.git --install-option test

    # to install and upgrade all dependencies regardless of version number
    python -m pip install --upgrade git+https://github.com/bitranox/lib_log_utils.git --upgrade-strategy eager


- include it into Your requirements.txt:

.. code-block:: bash

    # Insert following line in Your requirements.txt:
    # for the latest Release on pypi:
    lib_log_utils

    # for the latest development version :
    lib_log_utils @ git+https://github.com/bitranox/lib_log_utils.git

    # to install and upgrade all modules mentioned in requirements.txt:
    python -m pip install --upgrade -r /<path>/requirements.txt



- to install the latest development version from source code:

.. code-block:: bash

    # cd ~
    $ git clone https://github.com/bitranox/lib_log_utils.git
    $ cd lib_log_utils

    # to test without installing (can be skipped)
    python setup.py test

    # normal install
    python setup.py install

- via makefile:
  makefiles are a very convenient way to install. Here we can do much more,
  like installing virtual environments, clean caches and so on.

.. code-block:: shell

    # from Your shell's homedirectory:
    $ git clone https://github.com/bitranox/lib_log_utils.git
    $ cd lib_log_utils

    # to run the tests:
    $ make test

    # to install the package
    $ make install

    # to clean the package
    $ make clean

    # uninstall the package
    $ make uninstall

Usage
-----------

Python
-----------


import the module and check the code - it is very easy and documented there

as soon as I have some time, this will be completed (help welcome)


Commandline
-----------

.. code-block:: bash

   Usage:

        log_util (-h | --version | --program_info)
        log_util [Options] "<message>"
        log_util "<message>" [Options]

   Options:
        -h, --help          show help
        --version           show version
        --program_info      show Program Info


Arguments
---------

message
    the message to log



Options
-------

===========================  ====================================================================================
option                       description
===========================  ====================================================================================
-l --level <level>           the log level as number or predefined value, default = INFO
-b --banner                  log as banner
-w --width <width>           the width of the message or the banner, if text wrap is used, default = 140
-s --silent <True|False> **  disables the output if set to "True" (not case sensitive)**, default = False
-q --quiet                   disables the output (as flag), default = False
-f --force                   take precedence over environment settings, default = False
--wrap --nowrap              use text wrap (this is the default value), default = True
--traceback --no-traceback   show traceback on commandline error, default = False
===========================  ====================================================================================


\**This makes it possible to silence messages elegantly in a shellscript:

.. code-block:: bash

        #!/bin/bash

        # disable deprecation messages
        DEP_MSG_OFF="True"

       ...
       ...
       log_util -l warning "some deprecation message" --silent=${DEP_MSG_OFF}
       log_util -l info "another deprecation message" --silent=${DEP_MSG_OFF}
       ...


log levels
--------------------

=========   ===========
Text        Integer
=========   ===========
NOTSET      0
SPAM        5
DEBUG       10
VERBOSE     15
INFO        20
NOTICE      25
WARNING     30
SUCCESS     35
ERROR       40
CRITICAL    50
=========   ===========


Environment Settings
--------------------

======================  =======================================================================================
environment variable    function
======================  =======================================================================================
LOG_UTIL_LEVEL          the level of the logger, one of the predefined log levels, or "0" - "50", default = 0
LOG_UTIL_WIDTH          the banner width if text wrap is used, must be >="10", default = 140
LOG_UTIL_WRAP           if text wrap should be used, must be True or False (not case sensitive), default = True
LOG_UTIL_QUIET          if the logger is used at all - must be True or False (not case sensitive), default = False
======================  =======================================================================================

environment settings take precedence over commandline arguments, unless --force is passed to the commandline


EXAMPLES
--------


.. code-block:: bash

    # multi-line banner
    log_util -l warning "Line1${IFS}Line2${IFS}Line3"

    # use log_level
    export log_utils_log_level=WARNING

    log_util -l info   "spam"   # this is not shown
    log_util -l error  "ham"    # this is shown

    # disable log_level
    unset log_utils_log_level

Usage from Commandline
------------------------

.. code-block:: bash

   Usage: log_util [OPTIONS] [MESSAGE]

     colored log messages and banners from commandline and python

   Options:
     --version                     Show the version and exit.
     -b, --banner                  log as banner
     -w, --width INTEGER           wrap width, default=140
     --wrap / --nowrap             wrap text
     -s, --silent TEXT             disable logging if "True"
     -q, --quiet                   disable logging as flag
     -f, --force                   take precedence over environment settings
     -l, --level TEXT              log level as number or predefined Level
     --program_info                get program info
     -c, --colortest               color test
     --traceback / --no-traceback  return traceback information on cli
     -h, --help                    Show this message and exit.

Requirements
------------
following modules will be automatically installed :

.. code-block:: bash

    ## Project Requirements
    click
    coloredlogs
    lib_parameter @ git+https://github.com/bitranox/lib_parameter.git
    lib_platform @ git+https://github.com/bitranox/lib_platform.git
    lib_programname @ git+https://github.com/bitranox/lib_programname.git

Acknowledgements
----------------

- special thanks to "uncle bob" Robert C. Martin, especially for his books on "clean code" and "clean architecture"

Contribute
----------

I would love for you to fork and send me pull request for this project.
- `please Contribute <https://github.com/bitranox/lib_log_utils/blob/master/CONTRIBUTING.md>`_

License
-------

This software is licensed under the `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_

---

Changelog
=========

- new MAJOR version for incompatible API changes,
- new MINOR version for added functionality in a backwards compatible manner
- new PATCH version for backwards compatible bug fixes


0.1.2
-----
2020-07-16: feature release
    - store settings in environment for commandline use
    - cleanup
    - release on pypi
    - fix cli test
    - enable traceback option on cli errors
    - jupyter notebook

0.1.1
-----
2020-07-06: patch release
    - new click cli
    - use PizzaCutter Template

0.0.2
-----
development

0.0.1
-----
2019-09-03: Initial public release



