Metadata-Version: 2.4
Name: rdfc_log-processor
Version: 0.0.1
Summary: A simple Python processor to log an incoming stream to the console.
Project-URL: Homepage, https://rdf-connect.github.io
Project-URL: Repository, https://github.com/rdf-connect/log-processor-py
Project-URL: Issues, https://github.com/rdf-connect/log-processor-/issues
Author-email: Ieben Smessaert <ieben.smessaert@ugent.be>
License-Expression: MIT
Requires-Python: >=3.12
Requires-Dist: pytest-asyncio>=1.1.0
Requires-Dist: pytest>=8.4.1
Requires-Dist: rdfc-proto>=0.0.1
Requires-Dist: rdfc-runner>=0.0.1
Description-Content-Type: text/markdown

# log-processor-py

## Usage

To use the Python TemplateProcessor in your RDF-Connect pipeline, you need to have a pipeline configuration that includes the [rdfc:PyRunner](https://github.com/rdf-connect/py-runner) (check out their documentation to find out how to install and configure it).

You can install the Python runner package using the following command:

```shell
uv add rdfc_log-processor
```

Next, you can add the Python TemplateProcessor to your pipeline configuration as follows:

```turtle
@prefix rdfc: <https://w3id.org/rdf-connect#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.

# Import the processor
<> owl:imports <./.venv/lib/python3.13/site-packages/rdfc_template_processor/processor.ttl>.

### Define the channels your processor needs
<channel> a rdfc:Writer, rdfc:Reader.

# Attach the processor to the pipeline under the PyRunner
# Add the `rdfc:processor <template>` statement under the `rdfc:consistsOf` statement of the `rdfc:PyRunner`

### Define and configure the processors
<send> a rdfc:SendProcessorPy;
       rdfc:writer <channel>;
       rdfc:msg "Hello, World!", "Good afternoon, World!",
                "Good evening, World!", "Good night, World!".

<log> a rdfc:LogProcessorPy;
      rdfc:reader <channel>;
      rdfc:level "info";
      rdfc:label "test".
```

### Configuration

Parameters of `rdfc:SendProcessorPy`:
- `rdfc:writer`: The channel to which the processor will write messages.
- `rdfc:msg`: The messages to be sent by the processor.

Parameters of `rdfc:LogProcessorPy`:
- `rdfc:reader`: The channel from which the processor will read messages.
- `rdfc:writer`: The channel to which the processor will write log messages (optional).
- `rdfc:level`: The log level to use (e.g., "debug", "info", "warning", "error", "critical"). Defaults to "info".
- `rdfc:label`: A label for the log messages, which can be used to filter or categorize logs. Defaults to "log".
- `rdfc:raw`: If set to `true`, the processor will log raw messages to stdout without any formatting instead of to the RDF-Connect logging system. Defaults to `false`.


## Development

The [Packaging Python Projects](https://packaging.python.org/en/latest/tutorials/packaging-projects/) guide was used to set up this project.
As build backend, the default [Hatchling](https://hatch.pypa.io/latest/) is used, for which the `pyproject.toml` file is configured.
That file tells build frontend tools like [pip](https://pip.pypa.io/en/stable/) which backend to use.
This project uses [uv](https://docs.astral.sh/uv/) as package manager.

First, make sure you have [Hatch installed](https://hatch.pypa.io/latest/install/):

```shell
pip install hatch
# OR
brew install hatch
# OR another method of your choice
```

Then, create a virtual environment and spawn a shell. This will automatically install the project dependencies defined in `pyproject.toml`:

```shell
hatch env create
hatch shell
```

You can build the project with:

```shell
hatch build
```

Lastly, you can publish the package to PyPI with:

```shell
hatch publish
```


### Project Structure

```
log-processor-py/             # Root directory of the project
├── src/                      # Source code directory
│   └── rdfc_log_processor/   # Package directory
│       ├── __init__.py       # Package initialization, allows importing as a regular package
│       ├── processor.py      # Contains the main logic for the Python processor
│       └── processor.ttl     # RDF schema for the processor, used for metadata and configuration
├── tests/                    # Directory for unit tests
├── pyproject.toml            # Project metadata and build configuration
```