semvec/pypi-packages huggingface dataset:
surrogates 1.0.2
Encode and decode pairs of surrogate characters
License: MIT
Requires Python: >=3.5

# Surrogates

`surrogates` is a small, tested Python 3 package
to encode and decode pairs of
[surrogate characters](https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates)
in Python strings.
It is licensed under [the MIT license](https://opensource.org/licenses/MIT).


# Installation
```console
# pip3 install --user surrogates
```


# Usage

```console
# python3 -m IPython
[..]
In [1]: import surrogates

In [2]: surrogates.encode('��')
Out[2]: '\ud83d\ude18'

In [3]: surrogates.decode('\uD83D\uDE18')
Out[3]: '��'

In [4]: hex(ord('��'))
Out[4]: '0x1f618'
```


# Develop & run tests

```
cd "$(mktemp -d)"
git clone https://github.com/hartwork/surrogates
cd surrogates/
python3 -m venv py3
source py3/bin/activate
./setup.py test
```
json-pyformatter 0.1.0
Python logging module outputs logs as JSON.
License: MIT
Requires Python: >=3.7,<4.0
Keywords: python,json,logging,formatter

# json-pyformatter

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/homoluctus/json-pyformatter/Test)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/homoluctus/json-pyformatter?include_prereleases)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/json-pyformatter)
![GitHub](https://img.shields.io/github/license/homoluctus/json-pyformatter)

Python logging outputs as JSON.<br>
This JsonFormatter is written in Pure Python.

## Installation

```bash
pip install json-pyformatter
```

## Usage

```python
import logging
from json_pyformmatter import JsonFormatter

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
fields = ('levelname', 'filename', 'message')
handler.setFormatter(JsonFormatter(fields=fields))
logger.addHandler(hander)

logger.info('hello')
```

default fields is ('asctime', 'levelname', 'message')<br>
Other supported fields are:

|field name|description|
|:--:|:--|
|name|Name of the logger (logging channel)|
|levelno|Numeric logging level for the message<br>(DEBUG, INFO, WARNING, ERROR, CRITICAL)|
|levelname|Text logging level for the message<br>("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL")|
|pathname|Full pathname of the source file where the logging call was issued|
|filename|Filename portion of pathname|
|module|Module (name portion of filename)|
|lineno|Source line number where the logging call was issued|
|funcName|Function name|
|created|Time when the LogRecord was created (time.time()return value)|
|asctime|Textual time when the LogRecord was created|
|msecs|Millisecond portion of the creation time|
|relativeCreated|Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded (typically at application startup time)|
|thread|Thread ID|
|threadName|Thread name|
|process|Process ID|
|message|The result of record.getMessage(), computed just as the record is emitted|

In details, please refere to [logrecord-attributes](https://docs.python.org/3/library/logging.html#logrecord-attributes)

## Output

```bash
{"levelname": "INFO", "filename": "test_formatter.py", "message": "hello"}
```

If specify indent option as 2, the result is as follows:

```bash
{
  "levelname": "INFO",
  "filename": "test_formatter.py",
  "message": "hello"
}
```

When exc_info is True, the result includes traceback infomation as follows:

```bash
{
  'asctime': '2019-12-01 13:58:34',
  'levelname': 'ERROR',
  'message': 'error occurred !!',
  'traceback': [
    'Traceback (most rec...ll last):',
    'File "/example/test..._exc_info',
    'raise TypeError(message)',
    'TypeError: error occurred !!'
  ]
}
```

Logging message type is dict:

```bash
{
  'asctime': '2019-12-01 23:34:32',
  'levelname': 'INFO',
  'message': {
    'id': '001',
    'msg': 'This is test.',
    'name': 'test'
  }
}
```