Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
docs: rotating logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Aug 9, 2017
1 parent 4e58eff commit 008a9bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
18 changes: 16 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ Example Usage
except Exception as e:
logger.exception(e)
Adding a rotating logfile is that easy:

.. code-block:: python
import logzero
from logzero import logger
# Setup rotating logfile with 3 rotations, each with a maximum filesize of 1MB:
logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1e6, backupCount=3)
# Log messages
logger.info("This log message goes to the console and the logfile")
Here are more examples which show how to use logfiles, custom formatters
and setting a minimum loglevel:

Expand Down Expand Up @@ -133,8 +148,7 @@ You can also install `logzero` from the public `Github repo`_:
$ 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>`_.

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/
Expand Down
19 changes: 18 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can also install `logzero` from the public `Github repo`_:
$ 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/
Expand Down Expand Up @@ -103,6 +103,23 @@ If this was a file called ``demo.py``, the output will look like this:
Exception: this is a demo exception
Rotating Logfile
----------------

Adding a rotating logfile is that easy:

.. code-block:: python
import logzero
from logzero import logger
# Setup rotating logfile with 3 rotations, each with a maximum filesize of 1MB:
logzero.logfile("/tmp/rotating-logfile.log", maxBytes=1e6, backupCount=3)
# Log messages
logger.info("This log message goes to the console and the logfile")
Advanced Usage Examples
-----------------------

Expand Down

0 comments on commit 008a9bd

Please sign in to comment.