Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomtom-international/llvm-diagnostics
Python module for creating diagnostics using the LLVM diagnostics specification
https://github.com/tomtom-international/llvm-diagnostics
diagnostics llvm logging python
Last synced: 27 days ago
JSON representation
Python module for creating diagnostics using the LLVM diagnostics specification
- Host: GitHub
- URL: https://github.com/tomtom-international/llvm-diagnostics
- Owner: tomtom-international
- License: apache-2.0
- Created: 2022-05-03T09:49:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T13:49:31.000Z (12 months ago)
- Last Synced: 2024-12-18T12:49:12.516Z (about 1 month ago)
- Topics: diagnostics, llvm, logging, python
- Language: Python
- Homepage:
- Size: 78.1 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# llvm-diagnostics
Python module for creating diagnostics using the LLVM diagnostics specification
# Installation
```sh
% pip install llvm-diagnostics
```# Usage
## Parsing a log file containing LLVM Diagnostics messages
Parsing a logging file can be done as follows:
```python
from llvm_diagnostics.parser import diagnostics_messages_from_filefor error in list(diagnostics_messages_from_file("test/resources/test.out")):
print(f"Diagnostics Message found:")
print(f" File: {error.file_path}")
print(f" Level: {error.level}")
print(f" Message: {error.message}")
```Which will result in output similar to:
```sh
Diagnostics Message found:
File: /code/supermarket-buyer-supplier/src/offers/convert_customer_receipt.cpp
Level: DiagnosticsLevel.WARNING
Message: 'fruit_section' is deprecated: 2021.Q2 Deprecated Use application::supermarket_app::receipt_engine::receipt::FruitInformation::fruit_section_labels [-Wdeprecated-declarations]
```## Reporting on Diagnostics messages
You can use `llvm-diagnostics` to create your own Diagnostics messages.
### Reporting a message in LLVM Diagnostics format
```python
import llvm_diagnostics as loggermessage = logger.Warning(
file_path='fake_file.py',
line_number=logger.Range(start=10),
column_number=logger.Range(start=15, range=3),
line="mPercentage = 105",
expectations="100",
message='Value exceeds maximum, automatically capped to 100',
).report()
```
This will result in the following message on `stderr`:![example](resources/llvm_output_example.png)
### Reporting a message in GitHub format
```python
import llvm_diagnostics as loggerlogger.config(logger.formatters.GitHub())
message = logger.Warning(
file_path='fake_file.py',
line_number=logger.Range(start=10),
column_number=logger.Range(start=15, range=3),
line="mPercentage = 105",
expectations="100",
message='Value exceeds maximum, automatically capped to 100',
).report()
```This will result in the following message on `stderr`:
```sh
::warning file=fake_file.py,line=10,col=15,endColumn=18::Value exceeds maximum, automatically capped to 100
```