Skip to main content

sslog reader library

Project description

sslogread

Python reader module for the Speedy Structured C++17 logging library

See github repository for more details.

Installation

From pypi

python3 -m pip install sslogread

From sources

git clone https://github.com/dfeneyrou/sslog
cd sslog
mkdir build && cd build
cmake .. -DSSLOG_BUILD_PYTHON_READER=ON
make -j
python3 -m pip install python/dist/sslogread-*.whl

sslogread.load

This function (the unique one of the module) is the mandatory first step to work with logs.
It reads the meta information of the logs and creates the sslogread.LogSession objects with enables logs manipulation.

Declaration

def load(path)
Parameter name Type Description
path string The path of the log folder to represent

The returned value is a LogSession object if the loading succeeded. In case of failure, an exception with textual explanation is thrown.

The LogSession objects contains only two methods that are described in the following chapters:

Method name Description
query Filters logs and return them in a structured form.
This is the main service of the module.
get_strings Returns filtered unique strings.
This service is typically used to check user-defined consistency of category, name and unit strings.

Example

import sslogread

try:
    session = sslogread.load("/path/to/my/log_folder")
except Exception as e:
    print("Loading failed:", e)

sslogread.LogSession.query

This is the main service of the LogSession object. Logs are first filtered then returned in a structured form.

Declaration

The parameters are a list of dictionaries, each of them representing a filtering rule.
A logic OR is performed between them

def LogSession.query({ level_min:"trace", level_max:"off", category:"", thread:"", format:"", must_have_buffer:False, arguments:[],
                     no_category:"", no_thread:"", no_format:"", must_not_have_buffer:False }, { ... }, ... )

A filter rule is a dictionary containing one or many of the following key-value pairs (logic AND between them):

Parameter name Type Description Default (accept all)
'level_min' string The minimum log level 'trace'
'level_max' string The maximum log level (off is above all) 'off'
'category' string Filtering-in pattern on category ' '
'thread' string Filtering-in pattern on thread name ' '
'format' string Filtering-in pattern on format string ' '
buffer_size_min integer Filtering-in if buffer length is equal or above 0
buffer_size_max integer Filtering-in if buffer length is equal or below maximum size (4GB)
'arguments' [ strings ] Filtering-in on arguments names and value
(!) No pattern matching
' '
'no_category' string Filtering-out pattern on category ' '
'no_thread' string Filtering-out pattern on thread name ' '
'no_format' string Filtering-out pattern on format string ' '

[!IMPORTANT] Filtering on arguments is not pattern based. Names and values must be exact. The syntax is: <name><operator><value> with <operator> among =, ==, >, >=, <, <=
The <operator><value> can be ommitted to filter on the existence of a named argument.
Ex: "user==georges", "id=315", "weight<=50.0", "weight"

The returned value is a chronologic list of NamedTuples. The sslogread.Log structure is:

Parameter name Type Description
level string Log level
timestampUtcNs integer Log timestamp in nanosecond since UTC epoch
category string Log category
thread string Log thread name
format string Log format string already filled with arguments
arguments list of tuples List of log arguments as tuple (name, unit, typed value)
buffer string Log buffer in base64

Examples

Display all the logs (no filtering) in text:

result = session.query()
for log in result:
   print("%d) %s" % (log['timestampUtcNs'], log['format']))

Keep only the logs with a binary buffer and on a category matching *engine*:

result = session.query( { 'buffer_size_min': 1, 'category':'*engine*' } )

Select the logs on a category matching *engine* but not on a thread matching worker*

result = session.query( { 'no_thread': "worker*", 'category':'*engine*' } )

Select the logs which possess an argument named id and another named user

result = session.query( { 'arguments': ["id", "user"] } )

[!WARNING] The argument name shall be exact, no pattern matching for argument's names and values

Select the logs which possess an argument named user which has a value github_agent

result = session.query( { 'arguments': ["user==github_agent"] } ) # Note: '=' or '==' are identical

Select the logs on category transaction and which possess an argument named id which has a value higher than 356 and lower or equal to 1000

result = session.query( { 'category': "transaction", 'arguments': ["id>356", "id<=1000"] } )

Select the logs with level >= error, with category name containing 'car', which contain both an argument named 'color' and one named 'wheels' with value >= 4

result = session.query( { 'level_min':'error', 'category':'*car*', 'arguments':['color', 'wheels>=4'] } )

Select the logs on category transaction and which possess an argument named id which has a value higher than 356 and lower or equal to 1000
OR the logs with level >= error, with category name containing 'car', which contain both an argument named 'color' and one named 'wheels' with value >= 4

result = session.query( { 'category': "transaction", 'arguments': ["id>356", "id<=1000"] },
                        { 'level_min':'error', 'category':'*car*', 'arguments':['color', 'wheels>=4'] } )

sslogread.LogSession.get_strings

This method returns a list of strings matching both a content pattern and a selection of string flags.
It is basically a query on strings.

Declaration

def LogSession.get_strings(pattern="", in_category=False, in_thread=False, in_format=False, in_arg_name=False, in_arg_value=False, in_arg_unit=False)

[!TIP] If the pattern is empty, then all strings are accepted for this criteria.
If no flag on the string type is set, then all strings are accepted for these criteria.

Example

// Get strings used as a category, matching the pattern "/scheduler/*/worker"
strings = session.get_strings(pattern="/scheduler/*/worker", in_category=True)

// Get all thread name strings
strings = session.get_strings(in_thread=True)

// Get all format strings or argument value strings, containing the word "User"
strings = session.get_strings(pattern="*User*", in_format=True, in_arg_value=True)

License

Released under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sslogread-0.8.1.tar.gz (65.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sslogread-0.8.1-cp312-cp312-win_amd64.whl (592.3 kB view details)

Uploaded CPython 3.12Windows x86-64

sslogread-0.8.1-cp311-cp311-win_amd64.whl (592.2 kB view details)

Uploaded CPython 3.11Windows x86-64

sslogread-0.8.1-cp310-cp310-win_amd64.whl (592.2 kB view details)

Uploaded CPython 3.10Windows x86-64

sslogread-0.8.1-cp39-cp39-win_amd64.whl (592.2 kB view details)

Uploaded CPython 3.9Windows x86-64

sslogread-0.8.1-cp38-cp38-win_amd64.whl (592.2 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file sslogread-0.8.1.tar.gz.

File metadata

  • Download URL: sslogread-0.8.1.tar.gz
  • Upload date:
  • Size: 65.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1.tar.gz
Algorithm Hash digest
SHA256 d62b6061bd04d5797ee913dcba8b5e2868d36bbf3c3e701a0f5e653dd015a601
MD5 e0d6289e49e343bce8d16b5a1beda033
BLAKE2b-256 e8b833151bbafaa69dff1fb3c1cdf64c7f8cc6ba47e2af38ff438c90b962bc10

See more details on using hashes here.

File details

Details for the file sslogread-0.8.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sslogread-0.8.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 592.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e9074807b3fb4c534fbaee5057f3e57befd408d21bf677fd340ab65c794a6d9e
MD5 9f26ae7dc54288e4bf72dc75ae39ccb5
BLAKE2b-256 375ea102c5bf7be7efa22040d20a9837afe856bbb5d7c36df01c14bf4cbd274d

See more details on using hashes here.

File details

Details for the file sslogread-0.8.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sslogread-0.8.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 592.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e70bd3adb5d475f35d2bff4aa02fbce12bc3c08fbfbd3199702e47bf9b85a97
MD5 036183dc433570e0dfebee44eb0dd021
BLAKE2b-256 0678e57f8585aaffc87873b0d34a4bd63a466160e577911c2b785d8fb5baf7ee

See more details on using hashes here.

File details

Details for the file sslogread-0.8.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: sslogread-0.8.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 592.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 48d12b31b16a879d83069847621d8503cb85cb9e8d3daaa41257b2928c2f3f6d
MD5 09a5a1bc63716c7d7c59fa7a4b020464
BLAKE2b-256 6a2234a271bed04c3ed8de997d5e7dae1a63fcec250f6bf57b7ef5d691147593

See more details on using hashes here.

File details

Details for the file sslogread-0.8.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: sslogread-0.8.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 592.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fc09f65052235a93da66c5e8187bba9856d5652912f72b245b78f217cf213771
MD5 d91b0177e58ea839073b4e47dc298636
BLAKE2b-256 6b68b478bf7965817fc86ea8d773feb1bc53798a66c2e8df96e172859306065e

See more details on using hashes here.

File details

Details for the file sslogread-0.8.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sslogread-0.8.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 592.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for sslogread-0.8.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 789230a5f03c2ce38ac3fb31a315d93d44c2e99659f14938b62e7fc4f54ab593
MD5 77eeea54b89bb421a84e06958a21e237
BLAKE2b-256 f0107e5b0f4c3759e9072bbeb5b3f2174de4a872a2108d71017685aafb612669

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page