Python module for creating diagnostics using the LLVM diagnostics specification
Project description
llvm-diagnostics
Python module for creating diagnostics using the LLVM diagnostics specification
Installation
% pip install llvm-diagnostics
Usage
Parsing a log file containing LLVM Diagnostics messages
Parsing a logging file can be done as follows:
from llvm_diagnostics.parser import diagnostics_messages_from_file
for 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:
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
import llvm_diagnostics as logger
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
:
Reporting a message in GitHub format
import llvm_diagnostics as logger
logger.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
:
::warning file=fake_file.py,line=10,col=15,endColumn=18::Value exceeds maximum, automatically capped to 100
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llvm-diagnostics-3.0.0.tar.gz
(35.6 kB
view hashes)
Built Distribution
Close
Hashes for llvm_diagnostics-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1886897cecefbc26ef5e8ff2acaae3a0be1ca781d99b9b3dc6e41fd1171c0e9 |
|
MD5 | 7daf31d7a1d899d2f1933c1b1a623601 |
|
BLAKE2b-256 | 424fd0e4a8331e1d38a22dd61da9494aaed9d9b444620cb285c009969122796c |