Skip to content

Commit

Permalink
Merge 4831dcd into ec9ef81
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Oct 26, 2018
2 parents ec9ef81 + 4831dcd commit fb35273
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 70 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Revision History

## 1.1 (2018-10-26)

- Added `%(relpath)s` logging format.
- Added `verbosity` as `init()` option to work with Django admin commands.

## 1.0 (2018-09-27)

- Initial stable release.
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Expand Up @@ -22,6 +22,7 @@ pytest-expecter = "*"
pytest-random = "*"
pytest-ordering = "*"
pytest-cov = "*"
pathlib2 = "*" # missing dependency for Python 3.5

# Reports
coverage-space = "*"
Expand Down
164 changes: 138 additions & 26 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
Unix: [![Unix Build Status](https://img.shields.io/travis/jacebrowning/minilog/develop.svg)](https://travis-ci.org/jacebrowning/minilog) Windows: [![Windows Build Status](https://img.shields.io/appveyor/ci/jacebrowning/minilog/develop.svg)](https://ci.appveyor.com/project/jacebrowning/minilog)<br>Metrics: [![Coverage Status](https://img.shields.io/coveralls/jacebrowning/minilog/develop.svg)](https://coveralls.io/r/jacebrowning/minilog) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/jacebrowning/minilog.svg)](https://scrutinizer-ci.com/g/jacebrowning/minilog/?branch=develop)<br>Usage: [![PyPI Version](https://img.shields.io/pypi/v/minilog.svg)](https://pypi.org/project/minilog)
Unix: [![Unix Build Status](https://img.shields.io/travis/jacebrowning/minilog/develop.svg)](https://travis-ci.org/jacebrowning/minilog) Windows: [![Windows Build Status](https://img.shields.io/appveyor/ci/jacebrowning/minilog/develop.svg)](https://ci.appveyor.com/project/jacebrowning/minilog)<br>Metrics: [![Coverage Status](https://img.shields.io/coveralls/jacebrowning/minilog/develop.svg)](https://coveralls.io/r/jacebrowning/minilog) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/jacebrowning/minilog.svg)](https://scrutinizer-ci.com/g/jacebrowning/minilog/?branch=develop)<br>Usage: [![PyPI Version](https://img.shields.io/pypi/v/minilog.svg)](https://pypi.org/project/minilog) [![PyPI License](https://img.shields.io/pypi/l/minilog.svg)](https://pypi.org/project/minilog)

# Overview

Expand Down
54 changes: 54 additions & 0 deletions docs/extras.md
@@ -0,0 +1,54 @@
# Initialization

To customize logging formats and levels, `minilog` supports the same initialization arguments as [`logging.basicConfig`](https://docs.python.org/3/library/logging.html#logging.basicConfig). To set the format for all logging handlers:

```python
log.init(format="%(levelname)s: %(name)s: %(message)s")
```

To set the level for the root logging handler:

```python
log.init(format=<>, level=log.WARNING)
```

### Debug Option

To simply enable debug-level logging, a convenience option is provided:

```python
log.init(format=<>, debug=True)
```

### Verbosity Option

To work with frameworks that provide a `verbosity` level in their CLI frameworks (such as [Django](https://docs.djangoproject.com/en/2.1/ref/django-admin/#cmdoption-verbosity)), that can be used instead:

```python
log.init(format=<>, verbosity=verbosity)
```

### Silencing Loggers

To set the logging level for specific named loggers:

```python
log.silence('selenium')
log.silence('werkzeug', 'requests', allow_warning=True)
```

### Reset Loggers

Finally, if another package has already set the logging format or level, that can be reset so that `minilog` takes over:

```python
log.init(…, reset=True)
```

# Records

In addition to the standard [`LogRecord`](https://docs.python.org/3/library/logging.html#logrecord-attributes) attributes, the following additional patterns are available:

| Logging Format | Description
| --- | --- |
| `%(relpath)s` | Full pathname of the source file where the logging call was issued relative to the current working directory. |
30 changes: 1 addition & 29 deletions docs/api.md → docs/logging.md
@@ -1,4 +1,4 @@
# Logging
# API

This package intends to be a drop-in replacement for `logging.Logger` objects. It supports the standard logging API:

Expand Down Expand Up @@ -26,31 +26,3 @@ log.e(message, *args) # error

log.exc(message, *args) # exception
```

# Configuration

Set the format for all logging handlers:

```python
log.init(format="%(levelname)s: %(name)s: %(message)s")
```

Set the level for the root logging handler:

```python
log.init(format=<>, debug=True)
log.init(format=<>, level=log.WARNING)
```

Replace all existing loggers before initialization:

```python
log.init(reset=True, format=<>, level=<>)
```

Set the logging level for specific named loggers:

```python
log.silence('selenium')
log.silence('werkzeug', 'requests', allow_warning=True)
```
4 changes: 2 additions & 2 deletions log/__init__.py
@@ -1,7 +1,7 @@
from logging import DEBUG, INFO, WARNING, ERROR

from .logger import * # pylint: disable=wildcard-import
from .helpers import init, silence
from .helpers import init, install_additional_formats, silence

WARN = WARNING

Expand All @@ -13,4 +13,4 @@
exc = exception

__project__ = 'minilog'
__version__ = '1.0'
__version__ = '1.1'

0 comments on commit fb35273

Please sign in to comment.