← All procedures

logs.query

Query log entries from the database

MCPCLI
Package
@procedures/sqlite · README
Path
["logs","query"]
CLI
mark logs query
MCP tool
logs.query on the dev-tools server
As data
{"$proc":["logs","query"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/sqlite"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["logs","query"], {});
console.log(JSON.stringify(result));

From the command line

$ mark logs query

As data, in a program

{ "$proc": ["logs", "query"], "input": {} }

Input

FieldTypeRequiredDefaultDescription
sessionIdstringnoOnly the entries of this session
commandstringnoOnly the entries of this command
level"trace" | "debug" | "info" | "warn" | "error" | "trace" | "debug" | "info" | "warn" | "error"[]noOnly the entries of this level, or of these levels
limitintegernoThe most entries to give
offsetintegernoThe number of entries to skip (for pages)
orderBy"asc" | "desc"noThe order by time: desc (the default, newest first) or asc
dbPathstringnoThe SQLite database file (default: /home/runner/logs/cli/cli.db). A query does not make a missing file.

Output

FieldTypeRequiredDefaultDescription
logsobject[]yesThe entries that match the filters, in the order of orderBy
totalnumbernoThe number of entries that match the filters, without limit and offset
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "sessionId": {
        "description": "Only the entries of this session",
        "type": "string"
      },
      "command": {
        "description": "Only the entries of this command",
        "type": "string"
      },
      "level": {
        "description": "Only the entries of this level, or of these levels",
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "trace",
              "debug",
              "info",
              "warn",
              "error"
            ]
          },
          {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "trace",
                "debug",
                "info",
                "warn",
                "error"
              ]
            }
          }
        ]
      },
      "limit": {
        "description": "The most entries to give",
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "offset": {
        "description": "The number of entries to skip (for pages)",
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "orderBy": {
        "description": "The order by time: desc (the default, newest first) or asc",
        "type": "string",
        "enum": [
          "asc",
          "desc"
        ]
      },
      "dbPath": {
        "description": "The SQLite database file (default: /home/runner/logs/cli/cli.db). A query does not make a missing file.",
        "type": "string"
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "logs": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "number",
              "description": "The id of the log row"
            },
            "timestamp": {
              "type": "string",
              "description": "The time of the entry (SQLite datetime text, UTC)"
            },
            "level": {
              "type": "string",
              "enum": [
                "trace",
                "debug",
                "info",
                "warn",
                "error"
              ],
              "description": "The level of the entry"
            },
            "message": {
              "type": "string",
              "description": "The log message"
            },
            "data": {
              "anyOf": [
                {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                {
                  "type": "null"
                }
              ],
              "description": "The structured data of the entry, or null"
            },
            "sessionId": {
              "description": "The session of the entry, or null",
              "type": [
                "string",
                "null"
              ]
            },
            "command": {
              "description": "The command that made the entry, or null",
              "type": [
                "string",
                "null"
              ]
            },
            "context": {
              "description": "More context, or null",
              "type": [
                "string",
                "null"
              ]
            },
            "errorStack": {
              "description": "The stack trace of an error, or null",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "id",
            "timestamp",
            "level",
            "message",
            "data",
            "sessionId",
            "command",
            "context",
            "errorStack"
          ],
          "additionalProperties": {}
        },
        "description": "The entries that match the filters, in the order of orderBy"
      },
      "total": {
        "description": "The number of entries that match the filters, without limit and offset",
        "type": "number"
      }
    },
    "required": [
      "logs"
    ],
    "additionalProperties": {}
  }
}