Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
woutervh committed Apr 24, 2023
1 parent 9e0b767 commit 0806fbd
Show file tree
Hide file tree
Showing 25 changed files with 510 additions and 355 deletions.
23 changes: 14 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,27 @@
# >> alias source-env='set -a && source .env && set +a'

### project- directory-structure ###
# use double quotes if you use this in variable subsitutions
# use double quotes if you use this in variable subtitutions
BASE_DIR="__CWD__"
PROJECT_NAME='libranet-logging'
# PYTHON_LOG_DIR="__CWD__/var/log"
LOGGING_YML_FILE="__CWD__/etc/logging.yml"

IPYTHONDIR="__CWD__/etc/ipython"

# caching
# MYPY_CACHE_DIR, PYTEST_CACHE_DIR, RUFF_CACHE_DIR defined in pyproject.toml
CACHE_DIR="__CWD__/var/cache/"
DATA_DIR="__CWD__/var/data/"
DOWNLOAD_DIR="__CWD__/var/download/"
IPYTHONDIR="__CWD__/etc/ipython"
IPYTHON_CACHE_DIR="__CWD__/var/cache/ipython"
# MYPY_CACHE_DIR="__CWD__/var/cache/mypy"
BLACK_CACHE_DIR="__CWD__/var/cache/black"
IPYTHON_CACHE_DIR="__CWD__/var/cache/ipython"
PRE_COMMIT_HOME="__CWD__/var/cache/pre-commit"
PYLINTHOME="__CWD__/var/cache/pylint"
LOG_DIR="__CWD__/var/log"

# tmp
TMP="__CWD__/var/tmp"
TMPDIR="__CWD__/var/tmp"
TEMP="__CWD__/var/tmp"
TEMPDIR="__CWD__/var/tmp"

# logging
LOG_DIR="__CWD__/var/log"
LOGGING_YML_FILE="__CWD__/etc/logging.yml"
LOGGING_CFG="__CWD__/etc/logging.yml"
12 changes: 6 additions & 6 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
printenv PATH
poetry env info
- name: Flake8
run: |
make flake8
# - name: Flake8
# run: |
# make flake8

- name: Ruff
run: |
Expand All @@ -55,9 +55,9 @@ jobs:
run: |
make pylint
- name: Mypy
run: |
make mypy
# - name: Mypy
# run: |
# make mypy

- name: Pyroma
run: |
Expand Down
6 changes: 5 additions & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Changelog
1.4 (unreleased)
----------------

- Deprecate ``PYTHON_LOG_DIR``, use ``LOG_DIR`` instead.
- Change yaml-extension from ``*.yml`` to ``*.yaml``.

- Renamed environment-variable ``PYTHON_LOG_CONFIG`` into ````.

- Renamed environment-variable ``PYTHON_LOG_DIR`` into ``LOG_DIR``.

- Replace ``pkg_resources`` with ``importlib.resources``.

Expand Down
14 changes: 0 additions & 14 deletions docs/index-old.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ libranet-logging
:maxdepth: 2

readme
installation
usage
unittesting
changes
Expand All @@ -27,9 +26,6 @@ libranet-logging
modules/libranet_logging/index.rst





Indices and tables
==================

Expand Down
33 changes: 23 additions & 10 deletions docs/modules/libranet_logging/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ Submodules
:titlesonly:
:maxdepth: 1

cli/index.rst
filters/index.rst
logconfig/index.rst
loglevel/index.rst
utils/index.rst
validate/index.rst
yaml/index.rst


Expand All @@ -31,11 +32,11 @@ Functions

.. autoapisummary::

libranet_logging.print_loggers
libranet_logging.print_tree
libranet_logging.initialize
libranet_logging.output_logging_tree
libranet_logging.create_loglevel
libranet_logging.print_loggers
libranet_logging.print_tree



Expand All @@ -45,6 +46,8 @@ Attributes
.. autoapisummary::

libranet_logging.__version__
libranet_logging.__copyright__
libranet_logging.__license__
libranet_logging.create_loglevel_trace


Expand All @@ -53,19 +56,17 @@ Attributes



.. py:function:: print_loggers()
.. py:data:: __copyright__
:value: 'Copyright 2015 - 2023 Libranet'

Returns:


.. py:data:: __license__
:value: 'MIT License'

.. py:function:: print_tree()
Returns:



.. py:function:: initialize(path='', logdir='', capture_warnings=True, silent=False, use_print=False, variables=None)
.. py:function:: initialize(path='', logdir='', capture_warnings = True, silent = False, use_print = False, variables=None)
Initialize logging configuration with a yaml-file.

Expand Down Expand Up @@ -125,3 +126,15 @@ Attributes
.. py:function:: print_loggers()
Returns:



.. py:function:: print_tree()
Returns:



62 changes: 3 additions & 59 deletions docs/modules/libranet_logging/logconfig/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ Functions

.. autoapisummary::

libranet_logging.logconfig.is_interactive_shell
libranet_logging.logconfig.get_sorted_lognames
libranet_logging.logconfig.remove_console
libranet_logging.logconfig.ensure_dir
libranet_logging.logconfig.convert_filenames
libranet_logging.logconfig.remove_lower_level_handlers
libranet_logging.logconfig.validate_logging
libranet_logging.logconfig.strtobool
libranet_logging.logconfig.output_logging_tree
libranet_logging.logconfig.get_default_logging_yml
libranet_logging.logconfig.initialize
Expand All @@ -37,46 +33,16 @@ Attributes

.. autoapisummary::

libranet_logging.logconfig.cerberus
libranet_logging.logconfig.log
libranet_logging.logconfig.logging_schema


.. py:data:: cerberus


.. py:data:: log
.. py:data:: logging_schema
.. py:exception:: CerberusValidationError
Bases: :py:obj:`Exception`

CerberusValidationError-class.


.. py:function:: is_interactive_shell()
Decide if this process is run in an interactive shell or not.

If environment-variable $TERM is present,
we are running this code in a interactive shell,
else we are run from cron or called via nrpe as a nagios-check.

Returns: boolean



.. py:function:: get_sorted_lognames()
Returns:

Returns a sorted list of logging level names.


.. py:function:: remove_console(config, disable_console=False)
Expand All @@ -88,17 +54,9 @@ Attributes



.. py:function:: ensure_dir(directory)
:param directory:

Returns:



.. py:function:: convert_filenames(config, logdir='')
"Convert all relative filenames in the handlers to absolute paths.
"Convert relative filenames in the handlers to absolute paths.

:param config:
:param logdir:
Expand All @@ -122,20 +80,6 @@ Attributes



.. py:function:: validate_logging(log_config, path)
Validate the syntax of a logging.yml-file.


.. py:function:: strtobool(val)
Convert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.


.. py:function:: output_logging_tree(use_print=False)
:param use_print:
Expand All @@ -151,7 +95,7 @@ Attributes
:returns: A `Path` object representing the path to the default logging configuration file.


.. py:function:: initialize(path='', logdir='', capture_warnings=True, silent=False, use_print=False, variables=None)
.. py:function:: initialize(path='', logdir='', capture_warnings = True, silent = False, use_print = False, variables=None)
Initialize logging configuration with a yaml-file.

Expand Down
66 changes: 66 additions & 0 deletions docs/modules/libranet_logging/utils/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
:py:mod:`libranet_logging.utils`
================================

.. py:module:: libranet_logging.utils
.. autoapi-nested-parse::

libranet_logging.utils



Module Contents
---------------


Functions
~~~~~~~~~

.. autoapisummary::

libranet_logging.utils.print_tree
libranet_logging.utils.print_loggers
libranet_logging.utils.strtobool
libranet_logging.utils.is_interactive_shell
libranet_logging.utils.ensure_dir



.. py:function:: print_tree()
Returns:



.. py:function:: print_loggers()
Returns:



.. py:function:: strtobool(val)
Convert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.


.. py:function:: is_interactive_shell()
Decide if this process is run in an interactive shell or not.

If environment-variable $TERM is present,
we are running this code in a interactive shell,
else we are run from cron or called via nrpe as a nagios-check.

Returns: boolean



.. py:function:: ensure_dir(required_dir)
Ensure the required directory exists.


Loading

0 comments on commit 0806fbd

Please sign in to comment.