Skip to content

Commit

Permalink
added docs for new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BNMetrics committed Sep 28, 2018
1 parent b8e59f1 commit ae171c6
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 10 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
CHANGELOG
=========

1.3.0 (2018-09-28)
==================

**Improvement**

- Allowing configuration of `datefmt`, and `style` for master level `formatters` in logme.ini.
- This change does not break the previous version, you can still specify only the `fmt`
- Does not apply to `logme init` or `logme add {config_name}` command for generate automatic
- Default `style` will still be `{` if none specified
- example:

.. code-block:: ini
[my_config]
level = DEBUG
formatter =
fmt: {asctime} - {name} - {levelname} - {message}
datefmt: %Y/%m/%d
style: {
stream =
type: StreamHandler
active: True
level: DEBUG
file =
type: FileHandler
active: True
level: DEBUG
formatter: {name} :: {funcName} :: {levelname} :: {message}
filename: mylogpath/foo.log
1.2.1 (2018-06-01)
==================

Expand Down
38 changes: 34 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,47 @@ Logme is a Python package that makes logging simple and robust. If you have foun
logging in Python not so straight forward, download this package and give it a try! :)


v1.2.0 Updates
--------------

**logme** package now supports color and styling output in the terminal!
V1.3.0 Updates
---------------------
``logme.ini`` file now supports custome ``datefmt`` and ``style``! Thanks to `@afunTW <https://github.com/afunTW>`_ suggestion! :)

Here is an example of how you can specify these parameters in your ``logme.ini`` configuration:

.. code-block:: ini
[my_config]
level = DEBUG
formatter =
fmt: {asctime} - {name} - {levelname} - {message}
datefmt: %Y/%m/%d
style: {
stream =
type: StreamHandler
active: True
level: DEBUG
file =
type: FileHandler
active: True
level: DEBUG
formatter: {name} :: {funcName} :: {levelname} :: {message}
filename: mylogpath/foo.log
Note: Only top level ``master_formatter`` supports parameters as shown above, individual handler formatter will not.



Terminal Color Output
---------------------

**logme** supports color and styling output in the terminal!

The colors and style is **customizable** in ``logme.ini``, here is a screenshot of how it looks like in the terminal:


.. image:: http://logme.readthedocs.io/en/latest/_images/demo_color.png

To use color output in logme, make sure your logme package and ``logme.ini`` is `up-to-date <https://logme.readthedocs.io/en/latest/?badge=latest#upgrading>`_.
To use color output in logme, make sure your logme package and ``logme.ini`` is `up-to-date <https://logme.readthedocs.io/en/latest/?badge=latest#upgrading>`_ if you are using a version before 1.2.0.

Check the configuration details `here <https://logme.readthedocs.io/en/latest/guide/quickstart.html#colors>`_.

Expand Down
38 changes: 34 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,48 @@ Logme is a Python package that makes logging simple and robust. If you have foun
logging in Python not so straight forward, download this package and give it a try! :)


v1.2.0 Updates
--------------
V1.3.0 Updates
---------------------
_____________________________________________________________________

``logme.ini`` file now supports custome ``datefmt`` and ``style``! Thanks to `@afunTW <https://github.com/afunTW>`_ suggestion! :)

Here is an example of how you can specify these parameters in your ``logme.ini`` configuration:

.. code-block:: ini
[my_config]
level = DEBUG
formatter =
fmt: {asctime} - {name} - {levelname} - {message}
datefmt: %Y/%m/%d
style: {
stream =
type: StreamHandler
active: True
level: DEBUG
file =
type: FileHandler
active: True
level: DEBUG
formatter: {name} :: {funcName} :: {levelname} :: {message}
filename: mylogpath/foo.log
.. note:: Only top level `master_formatter` supports parameters as shown above, individual handler formatter will not.


Terminal Color Output
---------------------
_____________________________________________________________________

**logme** package now supports color and styling output in the terminal!
**logme** supports color and styling output in the terminal!

The colors and style is **customizable** in ``logme.ini``, here is a screenshot of how it looks like in the terminal:


.. image:: _images/demo_color.png

To use color output in logme, make sure your logme package and ``logme.ini`` is :ref:`up-to-date <upgrading>`.
To use color output in logme, make sure your logme package and ``logme.ini`` is :ref:`up-to-date <upgrading>` if you are using a version before 1.2.0.

Check the configuration details :ref:`here <colors>`.

Expand Down
3 changes: 2 additions & 1 deletion logme/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def _set_formatter(self, handler: logging.Handler, formatter_class: type,
"""
args = self._get_formatter_args(formatter)
formatter_object = formatter_class(**args)

handler.setFormatter(formatter_object)

def _handler_exist(self, handler: logging.Handler) -> bool:
Expand Down Expand Up @@ -400,7 +401,7 @@ def reset_config(self, config: str=None, config_dict: dict=None, name: str=None)
self._set_master_properties()
self._set_handlers_from_conf()

def reconfig_handler(self, handler_name: str, level: Union[str, int]=None, formatter: str=None):
def reconfig_handler(self, handler_name: str, level: Union[str, int]=None, formatter: Union[str, dict]=None):
"""
Reconfigure an existing handler's level and formatter.
*This can be used to configure a handler for a specific logger to be different from the config in Logme.ini*
Expand Down
2 changes: 1 addition & 1 deletion tests/logme.ini
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ null =
level = DEBUG
formatter =
fmt: {asctime} - {name} - {levelname} - {message}
datefmt: '%Y/%m/%d'
datefmt: %Y/%m/%d
style: {
stream =
type: StreamHandler
Expand Down

0 comments on commit ae171c6

Please sign in to comment.