Hello community, here is the log from the commit of package python-logzero for openSUSE:Factory checked in at 2020-12-09 22:12:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-logzero (Old) and /work/SRC/openSUSE:Factory/.python-logzero.new.2328 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-logzero" Wed Dec 9 22:12:48 2020 rev:8 rq:853807 version:1.6.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-logzero/python-logzero.changes 2020-11-07 21:03:27.237829233 +0100 +++ /work/SRC/openSUSE:Factory/.python-logzero.new.2328/python-logzero.changes 2020-12-09 22:12:49.603152517 +0100 @@ -1,0 +2,6 @@ +Wed Nov 25 20:51:51 UTC 2020 - Sebastian Wagner <[email protected]> + +- Update to version 1.6.3: + - no changelog available + +------------------------------------------------------------------- Old: ---- logzero-1.6.2.tar.gz New: ---- logzero-1.6.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-logzero.spec ++++++ --- /var/tmp/diff_new_pack.l4BhQC/_old 2020-12-09 22:12:50.099153021 +0100 +++ /var/tmp/diff_new_pack.l4BhQC/_new 2020-12-09 22:12:50.103153024 +0100 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-logzero -Version: 1.6.2 +Version: 1.6.3 Release: 0 Summary: A logging module for Python License: MIT ++++++ logzero-1.6.2.tar.gz -> logzero-1.6.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/HISTORY.md new/logzero-1.6.3/HISTORY.md --- old/logzero-1.6.2/HISTORY.md 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/HISTORY.md 2020-11-15 11:04:49.000000000 +0100 @@ -1,6 +1,12 @@ History ======= +1.6.1 (2020-11-15) +------------------ + +- JSON logging with UTF-8 enabled by default ([PR 357](https://github.com/metachris/logzero/pull/357)) + + 1.6.0 (2020-10-29) ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/PKG-INFO new/logzero-1.6.3/PKG-INFO --- old/logzero-1.6.2/PKG-INFO 2020-10-29 17:39:36.662010400 +0100 +++ new/logzero-1.6.3/PKG-INFO 2020-11-15 11:04:50.700741500 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: logzero -Version: 1.6.2 +Version: 1.6.3 Summary: Robust and effective logging for Python 2 and 3 Home-page: https://github.com/metachris/logzero Author: Chris Hager @@ -15,7 +15,7 @@ Robust and effective logging for Python 2 and 3. -  +  * Documentation: https://logzero.readthedocs.io * GitHub: https://github.com/metachris/logzero @@ -26,20 +26,18 @@ * Easy logging to console and/or (rotating) file. * Provides a fully configured standard [Python logger object](https://docs.python.org/2/library/logging.html#module-level-functions>). - * No dependencies + * JSON logging (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Pretty formatting, including level-specific colors in the console. + * No dependencies * Windows color output supported by [colorama](https://github.com/tartley/colorama) * Robust against str/bytes encoding problems, works with all kinds of character encodings and special characters. * Multiple loggers can write to the same logfile (also across multiple Python files and processes). - * JSON logging support (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Global default logger with [logzero.logger](https://logzero.readthedocs.io/en/latest/#i-logzero-logger) and custom loggers with [logzero.setup_logger(..)](https://logzero.readthedocs.io/en/latest/#i-logzero-setup-logger). * Compatible with Python 2 and 3. * All contained in a [single file](https://github.com/metachris/logzero/blob/master/logzero/__init__.py). * Licensed under the MIT license. * Heavily inspired by the [Tornado web framework](https://github.com/tornadoweb/tornado). -  - Example Usage ------------- @@ -57,54 +55,22 @@ raise Exception("this is a demo exception") except Exception as e: logger.exception(e) - ``` - Adding a rotating logfile is that easy: - - ```python + # JSON logging import logzero - from logzero import logger + logzero.json() - # Setup rotating logfile with 3 rotations, each with a maximum filesize of 1MB: - logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1e6, backupCount=3) + logger.info("JSON test") - # Log messages - logger.info("This log message goes to the console and the logfile") + # Start writing into a logfile + logzero.logfile("/tmp/logzero-demo.log") ``` - Here are more examples which show how to use logfiles, custom formatters - and setting a minimum loglevel: - - ```python - import logging - import logzero - from logzero import logger - - # This log message goes to the console - logger.debug("hello") + This is the output: - # Set a minimum log level - logzero.loglevel(logging.INFO) +  - # Set a logfile (all future log messages are also saved there) - logzero.logfile("/tmp/logfile.log") - - # You can also set a different loglevel for the file handler - logzero.logfile("/tmp/logfile.log", loglevel=logging.ERROR) - - # Set a rotating logfile (replaces the previous logfile handler) - logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1000000, backupCount=3) - - # Disable logging to a file - logzero.logfile(None) - - # Set a custom formatter - formatter = logging.Formatter('%(name)s - %(asctime)-15s - %(levelname)s: %(message)s'); - logzero.formatter(formatter) - - # Log some variables - logger.info("var1: %s, var2: %s", var1, var2) - ``` + Note: You can find more examples in the documentation: https://logzero.readthedocs.io ### JSON logging @@ -137,27 +103,19 @@ "process": 76204, "processName": "MainProcess", "threadName": "MainThread" - }``` + } + ``` - An exception logged with `logger.exception(e)` has these: + Exceptions logged with `logger.exception(e)` have these additional JSON fields: ```json { - "asctime": "2020-10-21 10:43:25,193", - "filename": "test.py", - "funcName": "test_this", "levelname": "ERROR", "levelno": 40, - "lineno": 17, - "module": "test", "message": "this is a demo exception", - "name": "logzero", - "pathname": "_tests/test.py", - "process": 76192, - "processName": "MainProcess", - "threadName": "MainThread", "exc_info": "Traceback (most recent call last):\n File \"_tests/test.py\", line 15, in test_this\n raise Exception(\"this is a demo exception\")\nException: this is a demo exception" - }``` + } + ``` Take a look at the documentation for more information and examples: @@ -169,8 +127,18 @@ Install `logzero` with [pip](https://pip.pypa.io): + ```shell - $ pip install -U logzero + # Create and activate a virtualenv in ./venv/ + python3 -m venv venv + . venv/bin/activate + + # Install logzero + python -m pip install logzero + + # Download and run demo.py + wget https://raw.githubusercontent.com/metachris/logzero/master/examples/demo.py + python demo.py ``` If you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide @@ -191,21 +159,26 @@ $ python setup.py install ``` - On openSUSE you can install the current version from repos: [python2-logzero](https://software.opensuse.org/package/python2-logzero), [python3-logzero](https://software.opensuse.org/package/python3-logzero). In the newest openSUSE release you can install it with zypper: `sudo zypper in python2-logzero`. + Contributors + ------------ + * [Chris Hager](https://github.com/metachris) + * [carlodr](https://github.com/carlodri) + * [Brian Lenz](https://github.com/brianlenz) + * [David Martin](https://github.com/dmartin35) + * [Zakaria Zajac](madzak) (creator of [python-json-logger](https://github.com/madzak/python-json-logger)) + + --- Development ----------- - Notes: - - * Using pytest as test runner - * CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). - * Download stats: https://pepy.tech/project/logzero - - ### Getting started + **Getting started** ```shell + $ git clone https://github.com/metachris/logzero.git + $ cd logzero + # Activate virtualenv $ python3 -m venv venv $ . venv/bin/activate @@ -222,12 +195,24 @@ # Generate the docs (will auto-open in Chrome) $ make docs + + # You can enable watching mode to automatically rebuild on changes: + $ make servedocs + ``` + + To test with Python 2.7, you can use Docker: + + ```shell + docker run --rm -it -v /Users/chris/stream/logzero:/mnt python:2.7 /bin/bash ``` - **To do** + Now you have a shell with the current directory mounted into `/mnt/` inside the container. - * CI to publish package to PyPI + **Notes** + * [pytest](https://docs.pytest.org/en/latest/) is the test runner + * CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). + * Download stats: https://pepy.tech/project/logzero --- @@ -242,14 +227,22 @@ All kinds of feedback and contributions are welcome. - * [Create an issue](https://github.com/metachris/logzero/issues/new>) + * [Create an issue](https://github.com/metachris/logzero/issues/new) * Create a pull request - * [@metachris](https://twitter.com/metachris) // [email protected] + * [@metachris](https://twitter.com/metachris) + +  History ======= + 1.6.1 (2020-11-15) + ------------------ + + - JSON logging with UTF-8 enabled by default ([PR 357](https://github.com/metachris/logzero/pull/357)) + + 1.6.0 (2020-10-29) ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/README.md new/logzero-1.6.3/README.md --- old/logzero-1.6.2/README.md 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/README.md 2020-11-15 11:04:49.000000000 +0100 @@ -7,7 +7,7 @@ Robust and effective logging for Python 2 and 3. - + * Documentation: https://logzero.readthedocs.io * GitHub: https://github.com/metachris/logzero @@ -18,20 +18,18 @@ * Easy logging to console and/or (rotating) file. * Provides a fully configured standard [Python logger object](https://docs.python.org/2/library/logging.html#module-level-functions>). -* No dependencies +* JSON logging (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Pretty formatting, including level-specific colors in the console. +* No dependencies * Windows color output supported by [colorama](https://github.com/tartley/colorama) * Robust against str/bytes encoding problems, works with all kinds of character encodings and special characters. * Multiple loggers can write to the same logfile (also across multiple Python files and processes). -* JSON logging support (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Global default logger with [logzero.logger](https://logzero.readthedocs.io/en/latest/#i-logzero-logger) and custom loggers with [logzero.setup_logger(..)](https://logzero.readthedocs.io/en/latest/#i-logzero-setup-logger). * Compatible with Python 2 and 3. * All contained in a [single file](https://github.com/metachris/logzero/blob/master/logzero/__init__.py). * Licensed under the MIT license. * Heavily inspired by the [Tornado web framework](https://github.com/tornadoweb/tornado). - - Example Usage ------------- @@ -49,54 +47,22 @@ raise Exception("this is a demo exception") except Exception as e: logger.exception(e) -``` - -Adding a rotating logfile is that easy: -```python +# JSON logging import logzero -from logzero import logger +logzero.json() -# Setup rotating logfile with 3 rotations, each with a maximum filesize of 1MB: -logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1e6, backupCount=3) +logger.info("JSON test") -# Log messages -logger.info("This log message goes to the console and the logfile") +# Start writing into a logfile +logzero.logfile("/tmp/logzero-demo.log") ``` -Here are more examples which show how to use logfiles, custom formatters -and setting a minimum loglevel: - -```python -import logging -import logzero -from logzero import logger +This is the output: -# This log message goes to the console -logger.debug("hello") + -# Set a minimum log level -logzero.loglevel(logging.INFO) - -# Set a logfile (all future log messages are also saved there) -logzero.logfile("/tmp/logfile.log") - -# You can also set a different loglevel for the file handler -logzero.logfile("/tmp/logfile.log", loglevel=logging.ERROR) - -# Set a rotating logfile (replaces the previous logfile handler) -logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1000000, backupCount=3) - -# Disable logging to a file -logzero.logfile(None) - -# Set a custom formatter -formatter = logging.Formatter('%(name)s - %(asctime)-15s - %(levelname)s: %(message)s'); -logzero.formatter(formatter) - -# Log some variables -logger.info("var1: %s, var2: %s", var1, var2) -``` +Note: You can find more examples in the documentation: https://logzero.readthedocs.io ### JSON logging @@ -129,27 +95,19 @@ "process": 76204, "processName": "MainProcess", "threadName": "MainThread" -}``` +} +``` -An exception logged with `logger.exception(e)` has these: +Exceptions logged with `logger.exception(e)` have these additional JSON fields: ```json { - "asctime": "2020-10-21 10:43:25,193", - "filename": "test.py", - "funcName": "test_this", "levelname": "ERROR", "levelno": 40, - "lineno": 17, - "module": "test", "message": "this is a demo exception", - "name": "logzero", - "pathname": "_tests/test.py", - "process": 76192, - "processName": "MainProcess", - "threadName": "MainThread", "exc_info": "Traceback (most recent call last):\n File \"_tests/test.py\", line 15, in test_this\n raise Exception(\"this is a demo exception\")\nException: this is a demo exception" -}``` +} +``` Take a look at the documentation for more information and examples: @@ -161,8 +119,18 @@ Install `logzero` with [pip](https://pip.pypa.io): + ```shell -$ pip install -U logzero +# Create and activate a virtualenv in ./venv/ +python3 -m venv venv +. venv/bin/activate + +# Install logzero +python -m pip install logzero + +# Download and run demo.py +wget https://raw.githubusercontent.com/metachris/logzero/master/examples/demo.py +python demo.py ``` If you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide @@ -183,21 +151,26 @@ $ python setup.py install ``` -On openSUSE you can install the current version from repos: [python2-logzero](https://software.opensuse.org/package/python2-logzero), [python3-logzero](https://software.opensuse.org/package/python3-logzero). In the newest openSUSE release you can install it with zypper: `sudo zypper in python2-logzero`. +Contributors +------------ + +* [Chris Hager](https://github.com/metachris) +* [carlodr](https://github.com/carlodri) +* [Brian Lenz](https://github.com/brianlenz) +* [David Martin](https://github.com/dmartin35) +* [Zakaria Zajac](madzak) (creator of [python-json-logger](https://github.com/madzak/python-json-logger)) +--- Development ----------- -Notes: - -* Using pytest as test runner -* CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). -* Download stats: https://pepy.tech/project/logzero - -### Getting started +**Getting started** ```shell +$ git clone https://github.com/metachris/logzero.git +$ cd logzero + # Activate virtualenv $ python3 -m venv venv $ . venv/bin/activate @@ -214,12 +187,24 @@ # Generate the docs (will auto-open in Chrome) $ make docs + +# You can enable watching mode to automatically rebuild on changes: +$ make servedocs ``` -**To do** +To test with Python 2.7, you can use Docker: -* CI to publish package to PyPI +```shell +docker run --rm -it -v /Users/chris/stream/logzero:/mnt python:2.7 /bin/bash +``` +Now you have a shell with the current directory mounted into `/mnt/` inside the container. + +**Notes** + +* [pytest](https://docs.pytest.org/en/latest/) is the test runner +* CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). +* Download stats: https://pepy.tech/project/logzero --- @@ -234,6 +219,8 @@ All kinds of feedback and contributions are welcome. -* [Create an issue](https://github.com/metachris/logzero/issues/new>) +* [Create an issue](https://github.com/metachris/logzero/issues/new) * Create a pull request -* [@metachris](https://twitter.com/metachris) // [email protected] +* [@metachris](https://twitter.com/metachris) + + Binary files old/logzero-1.6.2/docs/_static/demo-output-json.png and new/logzero-1.6.3/docs/_static/demo-output-json.png differ Binary files old/logzero-1.6.2/docs/_static/demo-output-with-beaver.png and new/logzero-1.6.3/docs/_static/demo-output-with-beaver.png differ Binary files old/logzero-1.6.2/docs/_static/logo-420.png and new/logzero-1.6.3/docs/_static/logo-420.png differ Binary files old/logzero-1.6.2/docs/_static/logo-big.png and new/logzero-1.6.3/docs/_static/logo-big.png differ Binary files old/logzero-1.6.2/docs/_static/logo-small.png and new/logzero-1.6.3/docs/_static/logo-small.png differ Binary files old/logzero-1.6.2/docs/_static/logo.png and new/logzero-1.6.3/docs/_static/logo.png differ Binary files old/logzero-1.6.2/docs/_static/logo_1000x500.png and new/logzero-1.6.3/docs/_static/logo_1000x500.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/docs/index.rst new/logzero-1.6.3/docs/index.rst --- old/logzero-1.6.2/docs/index.rst 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/docs/index.rst 2020-11-15 11:04:49.000000000 +0100 @@ -7,9 +7,8 @@ Robust and effective logging for Python 2 and 3. -.. image:: _static/logo-small.png +.. image:: _static/demo-output-with-beaver.png :alt: Logo - :width: 300px **Features** @@ -28,11 +27,6 @@ * Hosted on GitHub: https://github.com/metachris/logzero -.. image:: _static/demo_output.png - :alt: Demo output in color - :width: 300px - - Installation ============ @@ -53,9 +47,6 @@ $ cd logzero $ python setup.py install -On openSUSE you can install the current version from repos: `python2-logzero <https://software.opensuse.org/package/python2-logzero>`_, `python3-logzero <https://software.opensuse.org/package/python3-logzero>`_. -In the newest openSUSE release you can install it with zypper: ``sudo zypper in python2-logzero``. - .. _pip: https://pip.pypa.io .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ .. _Github repo: https://github.com/metachris/logzero @@ -74,10 +65,9 @@ from logzero import logger - # These log messages are sent to the console logger.debug("hello") logger.info("info") - logger.warning("warning") + logger.warning("warn") logger.error("error") # This is how you'd log an exception @@ -86,23 +76,19 @@ except Exception as e: logger.exception(e) -If this was a file called ``demo.py``, the output will look like this: + # JSON logging + import logzero + logzero.json() -.. image:: _static/demo_output_with_exception.png - :alt: Demo output in color + logger.info("JSON test") -.. code-block:: console + # Start writing into a logfile + logzero.logfile("/tmp/logzero-demo.log") - [D 170705 14:59:47 demo:3] hello - [I 170705 14:59:47 demo:4] info - [W 170705 14:59:47 demo:5] warn - [E 170705 14:59:47 demo:6] error - [E 170705 14:59:47 demo:12] this is a demo exception - Traceback (most recent call last): - File "demo.py", line 10, in <module> - raise Exception("this is a demo exception") - Exception: this is a demo exception +If this was a file called ``demo.py``, the output will look like this: +.. image:: _static/demo-output-json.png + :alt: Demo output in color Logging to files ---------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/docs/readme.rst new/logzero-1.6.3/docs/readme.rst --- old/logzero-1.6.2/docs/readme.rst 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/docs/readme.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -.. include:: ../README.rst diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/logzero/__init__.py new/logzero-1.6.3/logzero/__init__.py --- old/logzero-1.6.2/logzero/__init__.py 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/logzero/__init__.py 2020-11-15 11:04:49.000000000 +0100 @@ -50,7 +50,7 @@ __author__ = """Chris Hager""" __email__ = '[email protected]' -__version__ = '1.6.2' +__version__ = '1.6.3' # Python 2+3 compatibility settings for logger bytes_type = bytes @@ -97,7 +97,7 @@ colorama_init() -def setup_logger(name=__name__, logfile=None, level=logging.DEBUG, formatter=None, maxBytes=0, backupCount=0, fileLoglevel=None, disableStderrLogger=False, isRootLogger=False, json=False): +def setup_logger(name=__name__, logfile=None, level=logging.DEBUG, formatter=None, maxBytes=0, backupCount=0, fileLoglevel=None, disableStderrLogger=False, isRootLogger=False, json=False, json_ensure_ascii=False): """ Configures and returns a fully configured logger instance, no hassles. If a logger with the specified name already exists, it returns the existing instance, @@ -124,6 +124,7 @@ :arg bool disableStderrLogger: Should the default stderr logger be disabled. Defaults to False. :arg bool isRootLogger: If True then returns a root logger. Defaults to False. (see also the `Python docs <https://docs.python.org/3/library/logging.html#logging.getLogger>`_). :arg bool json: If True then log in JSON format. Defaults to False. (uses `python-json-logger <https://github.com/madzak/python-json-logger>`_). + :arg bool json_ensure_ascii: Passed to json.dumps as `ensure_ascii`, default: False (if False: writes utf-8 characters, if True: ascii only representation of special characters - eg. '\u00d6\u00df') :return: A fully configured Python logging `Logger object <https://docs.python.org/2/library/logging.html#logger-objects>`_ you can use with ``.debug("msg")``, etc. """ _logger = logging.getLogger(None if isRootLogger else name) @@ -134,7 +135,7 @@ _logger.setLevel(minLevel) # Setup default formatter - _formatter = _get_json_formatter() if json else formatter or LogFormatter() + _formatter = _get_json_formatter(json_ensure_ascii) if json else formatter or LogFormatter() # Reconfigure existing handlers stderr_stream_handler = None @@ -487,15 +488,18 @@ return syslog_handler -def json(enable=True, update_custom_handlers=False): +def json(enable=True, json_ensure_ascii=False, update_custom_handlers=False): """ Enable/disable json logging for all handlers. + + Params: + * json_ensure_ascii ... Passed to json.dumps as `ensure_ascii`, default: False (if False: writes utf-8 characters, if True: ascii only representation of special characters - eg. '\u00d6\u00df') """ - formatter(_get_json_formatter() if enable else LogFormatter(), update_custom_handlers=update_custom_handlers) + formatter(_get_json_formatter(json_ensure_ascii) if enable else LogFormatter(), update_custom_handlers=update_custom_handlers) -def _get_json_formatter(): +def _get_json_formatter(json_ensure_ascii): supported_keys = [ 'asctime', 'filename', @@ -515,7 +519,7 @@ def log_format(x): return ['%({0:s})s'.format(i) for i in x] custom_format = ' '.join(log_format(supported_keys)) - return JsonFormatter(custom_format) + return JsonFormatter(custom_format, json_ensure_ascii=json_ensure_ascii) def log_function_call(func): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/logzero/jsonlogger.py new/logzero-1.6.3/logzero/jsonlogger.py --- old/logzero-1.6.2/logzero/jsonlogger.py 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/logzero/jsonlogger.py 2020-11-15 11:04:49.000000000 +0100 @@ -10,6 +10,8 @@ import re import traceback import importlib +from inspect import istraceback +from collections import OrderedDict from datetime import date, datetime, time if sys.version_info >= (3, ): @@ -19,10 +21,6 @@ tz = None -from inspect import istraceback - -from collections import OrderedDict - # skip natural LogRecord attributes # http://docs.python.org/library/logging.html#logrecord-attributes RESERVED_ATTRS = ( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/logzero.egg-info/PKG-INFO new/logzero-1.6.3/logzero.egg-info/PKG-INFO --- old/logzero-1.6.2/logzero.egg-info/PKG-INFO 2020-10-29 17:39:36.000000000 +0100 +++ new/logzero-1.6.3/logzero.egg-info/PKG-INFO 2020-11-15 11:04:50.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: logzero -Version: 1.6.2 +Version: 1.6.3 Summary: Robust and effective logging for Python 2 and 3 Home-page: https://github.com/metachris/logzero Author: Chris Hager @@ -15,7 +15,7 @@ Robust and effective logging for Python 2 and 3. -  +  * Documentation: https://logzero.readthedocs.io * GitHub: https://github.com/metachris/logzero @@ -26,20 +26,18 @@ * Easy logging to console and/or (rotating) file. * Provides a fully configured standard [Python logger object](https://docs.python.org/2/library/logging.html#module-level-functions>). - * No dependencies + * JSON logging (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Pretty formatting, including level-specific colors in the console. + * No dependencies * Windows color output supported by [colorama](https://github.com/tartley/colorama) * Robust against str/bytes encoding problems, works with all kinds of character encodings and special characters. * Multiple loggers can write to the same logfile (also across multiple Python files and processes). - * JSON logging support (with integrated [python-json-logger](https://github.com/madzak/python-json-logger)) * Global default logger with [logzero.logger](https://logzero.readthedocs.io/en/latest/#i-logzero-logger) and custom loggers with [logzero.setup_logger(..)](https://logzero.readthedocs.io/en/latest/#i-logzero-setup-logger). * Compatible with Python 2 and 3. * All contained in a [single file](https://github.com/metachris/logzero/blob/master/logzero/__init__.py). * Licensed under the MIT license. * Heavily inspired by the [Tornado web framework](https://github.com/tornadoweb/tornado). -  - Example Usage ------------- @@ -57,54 +55,22 @@ raise Exception("this is a demo exception") except Exception as e: logger.exception(e) - ``` - Adding a rotating logfile is that easy: - - ```python + # JSON logging import logzero - from logzero import logger + logzero.json() - # Setup rotating logfile with 3 rotations, each with a maximum filesize of 1MB: - logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1e6, backupCount=3) + logger.info("JSON test") - # Log messages - logger.info("This log message goes to the console and the logfile") + # Start writing into a logfile + logzero.logfile("/tmp/logzero-demo.log") ``` - Here are more examples which show how to use logfiles, custom formatters - and setting a minimum loglevel: - - ```python - import logging - import logzero - from logzero import logger - - # This log message goes to the console - logger.debug("hello") + This is the output: - # Set a minimum log level - logzero.loglevel(logging.INFO) +  - # Set a logfile (all future log messages are also saved there) - logzero.logfile("/tmp/logfile.log") - - # You can also set a different loglevel for the file handler - logzero.logfile("/tmp/logfile.log", loglevel=logging.ERROR) - - # Set a rotating logfile (replaces the previous logfile handler) - logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1000000, backupCount=3) - - # Disable logging to a file - logzero.logfile(None) - - # Set a custom formatter - formatter = logging.Formatter('%(name)s - %(asctime)-15s - %(levelname)s: %(message)s'); - logzero.formatter(formatter) - - # Log some variables - logger.info("var1: %s, var2: %s", var1, var2) - ``` + Note: You can find more examples in the documentation: https://logzero.readthedocs.io ### JSON logging @@ -137,27 +103,19 @@ "process": 76204, "processName": "MainProcess", "threadName": "MainThread" - }``` + } + ``` - An exception logged with `logger.exception(e)` has these: + Exceptions logged with `logger.exception(e)` have these additional JSON fields: ```json { - "asctime": "2020-10-21 10:43:25,193", - "filename": "test.py", - "funcName": "test_this", "levelname": "ERROR", "levelno": 40, - "lineno": 17, - "module": "test", "message": "this is a demo exception", - "name": "logzero", - "pathname": "_tests/test.py", - "process": 76192, - "processName": "MainProcess", - "threadName": "MainThread", "exc_info": "Traceback (most recent call last):\n File \"_tests/test.py\", line 15, in test_this\n raise Exception(\"this is a demo exception\")\nException: this is a demo exception" - }``` + } + ``` Take a look at the documentation for more information and examples: @@ -169,8 +127,18 @@ Install `logzero` with [pip](https://pip.pypa.io): + ```shell - $ pip install -U logzero + # Create and activate a virtualenv in ./venv/ + python3 -m venv venv + . venv/bin/activate + + # Install logzero + python -m pip install logzero + + # Download and run demo.py + wget https://raw.githubusercontent.com/metachris/logzero/master/examples/demo.py + python demo.py ``` If you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide @@ -191,21 +159,26 @@ $ python setup.py install ``` - On openSUSE you can install the current version from repos: [python2-logzero](https://software.opensuse.org/package/python2-logzero), [python3-logzero](https://software.opensuse.org/package/python3-logzero). In the newest openSUSE release you can install it with zypper: `sudo zypper in python2-logzero`. + Contributors + ------------ + * [Chris Hager](https://github.com/metachris) + * [carlodr](https://github.com/carlodri) + * [Brian Lenz](https://github.com/brianlenz) + * [David Martin](https://github.com/dmartin35) + * [Zakaria Zajac](madzak) (creator of [python-json-logger](https://github.com/madzak/python-json-logger)) + + --- Development ----------- - Notes: - - * Using pytest as test runner - * CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). - * Download stats: https://pepy.tech/project/logzero - - ### Getting started + **Getting started** ```shell + $ git clone https://github.com/metachris/logzero.git + $ cd logzero + # Activate virtualenv $ python3 -m venv venv $ . venv/bin/activate @@ -222,12 +195,24 @@ # Generate the docs (will auto-open in Chrome) $ make docs + + # You can enable watching mode to automatically rebuild on changes: + $ make servedocs + ``` + + To test with Python 2.7, you can use Docker: + + ```shell + docker run --rm -it -v /Users/chris/stream/logzero:/mnt python:2.7 /bin/bash ``` - **To do** + Now you have a shell with the current directory mounted into `/mnt/` inside the container. - * CI to publish package to PyPI + **Notes** + * [pytest](https://docs.pytest.org/en/latest/) is the test runner + * CI is run with [Github actions](https://github.com/metachris/logzero/tree/master/.github/workflows). + * Download stats: https://pepy.tech/project/logzero --- @@ -242,14 +227,22 @@ All kinds of feedback and contributions are welcome. - * [Create an issue](https://github.com/metachris/logzero/issues/new>) + * [Create an issue](https://github.com/metachris/logzero/issues/new) * Create a pull request - * [@metachris](https://twitter.com/metachris) // [email protected] + * [@metachris](https://twitter.com/metachris) + +  History ======= + 1.6.1 (2020-11-15) + ------------------ + + - JSON logging with UTF-8 enabled by default ([PR 357](https://github.com/metachris/logzero/pull/357)) + + 1.6.0 (2020-10-29) ------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/logzero.egg-info/SOURCES.txt new/logzero-1.6.3/logzero.egg-info/SOURCES.txt --- old/logzero-1.6.2/logzero.egg-info/SOURCES.txt 2020-10-29 17:39:36.000000000 +0100 +++ new/logzero-1.6.3/logzero.egg-info/SOURCES.txt 2020-11-15 11:04:50.000000000 +0100 @@ -10,11 +10,14 @@ docs/contributing.rst docs/index.rst docs/make.bat -docs/readme.rst +docs/_static/demo-output-json.png +docs/_static/demo-output-with-beaver.png docs/_static/demo_output.png docs/_static/demo_output_with_exception.png -docs/_static/logo-small.png +docs/_static/logo-420.png +docs/_static/logo-big.png docs/_static/logo.png +docs/_static/logo_1000x500.png logzero/__init__.py logzero/colors.py logzero/jsonlogger.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/setup.cfg new/logzero-1.6.3/setup.cfg --- old/logzero-1.6.2/setup.cfg 2020-10-29 17:39:36.662010400 +0100 +++ new/logzero-1.6.3/setup.cfg 2020-11-15 11:04:50.700741500 +0100 @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.6.2 +current_version = 1.6.3 commit = True tag = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/setup.py new/logzero-1.6.3/setup.py --- old/logzero-1.6.2/setup.py 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/setup.py 2020-11-15 11:04:49.000000000 +0100 @@ -13,7 +13,7 @@ setup( name='logzero', - version='1.6.2', + version='1.6.3', description="Robust and effective logging for Python 2 and 3", long_description=readme + '\n\n' + history, long_description_content_type='text/markdown', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logzero-1.6.2/tests/test_json.py new/logzero-1.6.3/tests/test_json.py --- old/logzero-1.6.2/tests/test_json.py 2020-10-29 17:39:31.000000000 +0100 +++ new/logzero-1.6.3/tests/test_json.py 2020-11-15 11:04:49.000000000 +0100 @@ -58,3 +58,34 @@ finally: temp.close() + + +def test_json_encoding(capsys): + """ + see logzero.json(json_ensure_ascii=True) + """ + logzero.reset_default_logger() + + # UTF-8 mode + logzero.json(json_ensure_ascii=False) + logzero.logger.info('ß') + out, err = capsys.readouterr() + json.loads(err) # make sure JSON is valid + assert 'ß' in err + assert 'u00df' not in err + + # ASCII mode + logzero.json(json_ensure_ascii=True) + logzero.logger.info('ß') + out, err = capsys.readouterr() + json.loads(err) # make sure JSON is valid + assert 'u00df' in err + assert 'ß' not in err + + # Default JSON mode should be utf-8 + logzero.json() + logzero.logger.info('ß') + out, err = capsys.readouterr() + json.loads(err) # make sure JSON is valid + assert 'ß' in err + assert 'u00df' not in err _______________________________________________ openSUSE Commits mailing list -- [email protected] To unsubscribe, email [email protected] List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/[email protected]
