Skip to content

Add JSON representation for tree of logs #1

Description

@okt-limonikas

Problem

  • We want to reuse existing Bublik UI to display logs locally
  • We already can export logs as JSON but we also need way to navigate between logs locally
  • For it we need to create JSON representation of the tree of logs

image

Solution

  • Output JSON logs to a folder with tree.json which would act as a manifest for logs
  • Locally you can install special executable to open and navigate logs just like in Bublik
  • Current proof of concept is at https://github.com/okt-limonikas/bublik-log-viewer

How it works

  1. User can install executable to view local logs (refer to README.md for instructions on how to install)
  2. User can update executable via command

Current API includes 2 main commands:

  • bublik-log-viewer serve <path_to_logs_folder> --open
    This will spin up http server and open browser to view JSON logs from provided folder

  • bublik-log-viewer update -> to update to latest version

Example

You can see example at https://github.com/okt-limonikas/bublik-log-viewer/tree/main/example/logs

  • Basically folder contains mostly logs in the form of files like node_id1269601.json
  • Also contains tree.json which acts like manifest

This tree.json is following this JSON schema:

You can omit 'start' field in example

{
  "type": "object",
  "properties": {
    "main_package": { "type": "number" },
    "tree": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "id": { "type": "number" },
          "name": { "type": "string" },
          "entity": { "type": "string", "enum": ["pkg", "session", "test"] },
          "has_error": { "type": "boolean" },
          "skipped": { "type": "boolean" },
          "start": { "type": "string" },
          "children": { "type": "array", "items": { "type": "number" } }
        },
        "required": ["id", "name", "entity", "has_error", "skipped", "start"],
        "additionalProperties": false
      }
    }
  },
  "required": ["main_package", "tree"],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Here's example of this tree: https://github.com/okt-limonikas/bublik-log-viewer/blob/main/example/logs/tree.json

Run example

If you want to test this out fastest way is using docker:

  1. Clone repo git clone git@github.com:okt-limonikas/bublik-log-viewer.git
  2. Build docker build -t log-viewer .
  3. Serve logs from example json folder docker run -it -v $(pwd)/example/logs:/root/json -p 5050:5050 log-viewer
  4. Visit http://127.0.0.1:5050 to view logs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions