• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

sqlitelogs

Remix of maxm/sqlitelogs
Public
Like
sqlitelogs
Home
Code
5
.vtignore
README.md
deno.json
logger.tsx
H
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
4/15/2025
Viewing readonly version of main branch: v2
View latest version
README.md

Val Town Logger

A simple, powerful logging system for Val Town that stores logs in SQLite and provides both a web interface and API for viewing and searching logs.

Features

  • πŸ“ Log any data type with automatic formatting
  • πŸ” Search logs with full-text search
  • πŸ“Š Clean, dark-themed web interface
  • πŸ“± Responsive design that works on mobile and desktop
  • πŸ”„ Pagination and sorting options
  • πŸ”Œ API access for programmatic log retrieval

Usage

Logging Data

Import the log function from the logger module and use it to log any data:

import { log } from "./logger.tsx"; // Log simple messages await log("User signed up"); // Log multiple values await log("User", userId, "performed action", actionType); // Log objects and complex data await log("Request data:", requestObject); await log("Error occurred:", errorObject);

The logger automatically formats and stores all data types appropriately.

Viewing Logs

Access the web interface by visiting the val's URL without any path parameters. The interface provides:

  • Search functionality
  • Pagination controls
  • Sorting options (newest/oldest first)
  • Expandable log entries (click on any log to see the full content)
  • Adjustable items per page

API Access

To access logs programmatically, append /api to the val's URL. The API supports the following query parameters:

  • search: Text to search for in logs
  • page: Page number (default: 1)
  • limit: Number of logs per page (default: 50)
  • order: Sort order, either asc or desc (default: desc)

Example API request:

https://your-val-url.val.run/api?search=error&page=1&limit=25&order=desc

API response format:

{ "rows": [ { "id": 123, "line": "Error occurred: TypeError: Cannot read property 'x' of undefined", "ts": "2023-06-15T14:32:45.123Z" }, // More log entries... ], "pagination": { "total": 42, "page": 1, "limit": 25, "pages": 2 } }

Implementation Details

The logger uses SQLite for storage with a table structure that includes:

  • id: Unique identifier for each log entry
  • line: The formatted log message
  • ts: Timestamp when the log was created

Development

To modify this logger:

  1. Update the table prefix in logger.tsx if you want to create a new version with schema changes
  2. Customize the UI styling in the CSS section of main.tsx
  3. Add additional search or filtering capabilities by modifying the getLogs function

License

Feel free to use, modify, and share this logger for your Val Town projects.

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.