|
1 | 1 | Unclogger |
2 | 2 | ========= |
3 | 3 |
|
4 | | -Simple library for customisable structured logging. |
| 4 | +Simple Python library for customizable structured logging. |
5 | 5 |
|
| 6 | +## Quick Intro |
6 | 7 |
|
7 | | -## Development Environment |
8 | | - |
9 | | -[Poetry](https://python-poetry.org) is used for dependency and package management. The steps for setting up the development environment: |
10 | | - |
11 | | -1. Install Poetry: either [globally](https://python-poetry.org/docs/#installation), or in a Python virtual environment (using `pip install poetry`). |
12 | | - |
13 | | -3. Install the project (if outside a virtual environment, Poetry will create one): |
14 | | - |
15 | | - $ poetry install |
16 | | - |
17 | | - |
18 | | -### Development Checks |
19 | | - |
20 | | -During development, a number of checks and tests can be executed on the library codebase: |
21 | | - |
22 | | -```shell |
23 | | -$ pylint unclogger/ # code linting |
24 | | -$ mypy --install-types --non-interactive unclogger/ # Python typing analysis |
25 | | -$ black --check . # Python code formatting |
26 | | -$ isort --check . # Import statement optimisation |
27 | | -$ pydocstyle unclogger/ # styling and completeness of docstrings |
28 | | -``` |
29 | | - |
30 | | -Unit tests can be executed using: |
31 | | - |
32 | | -```shell |
33 | | -$ pytest --cov --spec |
34 | | -``` |
35 | | - |
36 | | -The indicated options add extra details to the report: |
37 | | - |
38 | | -* `--cov` adds a test coverage report |
39 | | -* `--spec` formats the test report as a list of spec statementss |
40 | | - |
41 | | - |
42 | | -## API Documentation |
43 | | - |
44 | | -The project documentation can be served locally by running: |
45 | | - |
46 | | -```shell |
47 | | -$ mkdocs serve |
| 8 | + ```python |
| 9 | +from unclogger import get_logger |
| 10 | +logger = get_logger("test logger") |
| 11 | +logger.info("test test", foo="abc", bar=123) |
48 | 12 | ``` |
49 | 13 |
|
50 | | -To build the static documentation site, run: |
51 | | - |
52 | | -```shell |
53 | | -$ mkdocs build |
| 14 | +Output: |
| 15 | +```json |
| 16 | +{ |
| 17 | + "foo": "abc", |
| 18 | + "bar": 123, |
| 19 | + "event": "test test", |
| 20 | + "logger": "test logger", |
| 21 | + "level": "info", |
| 22 | + "timestamp": "2021-02-12T22:40:07.600385Z" |
| 23 | +} |
54 | 24 | ``` |
55 | | - |
56 | | -This will create the HTML documentation in the `site` directory. |
0 commit comments