Skip to main content

ML3Log

A minimal Python logging package that provides both console logging and a web interface to view logs.

Features

  • Standard Python logger compatible
  • Web server for viewing logs in real-time
  • Minimal footprint with no external dependencies
  • Configurable port (default: 6020)
  • Monkey patching support for standard logging module
  • Command-line interface for quick server startup

Installation

pip install ml3log

Usage

Starting the server

From Python code

import ml3log

# Start the server on the default port (6020)
ml3log.start_server()

# Or specify a custom port
ml3log.start_server(port=8080)

From the command line

ML3Log can be started directly from the command line:

# Using the ml3log command (after installation)
ml3log

# Or with custom host and port
ml3log --host 0.0.0.0 --port 8080

# Alternatively, using the Python module syntax
python -m ml3log

Using the logger

import ml3log
import logging

# Get a logger with default settings
logger = ml3log.get_logger("my_app")

# Or customize the logger
logger = ml3log.get_logger(
    name="my_app",
    level=logging.DEBUG,
    host="localhost",
    port=6020
)

# Alternatively, monkey patch the standard logging module
# to capture logs from libraries using standard logging
ml3log.monkey_patch_logging()

# Use like a standard Python logger
logger.info("This is an info message")
logger.warning("This is a warning")
logger.error("This is an error")
logger.debug("This is a debug message")

# Log exceptions
try:
    1/0
except Exception as e:
    logger.exception("An error occurred")

Sending logs from JavaScript

You can send logs directly from JavaScript to ML3Log using a simple fetch request:

// Minimal example to send a log event to ML3Log
async function sendLog(message, level = 'INFO', loggerName = 'js-client') {
  const logEntry = {
    levelname: level,
    name: loggerName,
    message: message,
    created: Date.now() / 1000  // Current time in seconds
  };

  try {
    const response = await fetch('http://localhost:6020/traces', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(logEntry)
    });
    return response.ok;
  } catch (error) {
    console.error('Failed to send log:', error);
    return false;
  }
}

// Usage examples
sendLog('User clicked submit button');
sendLog('API request failed', 'ERROR');
sendLog('Debug information', 'DEBUG', 'frontend-app');

Viewing logs

Open your browser and navigate to:

http://localhost:6020

The web interface will automatically update with new logs as they arrive.

Screenshot

License

MIT

Metadata

Release files for ml3log 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ml3log 0.1.1
File Size Uploaded Provenance Actions
ml3log-0.1.1.tar.gz 15.0 kB Without provenance Details for ml3log-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ml3log 0.1.1
File Interpreter ABI Platform Actions
ml3log-0.1.1-py3-none-any.whl Python 3 none any Details for ml3log-0.1.1-py3-none-any.whl

Total release size: 30.3 kB

Release files / ml3log-0.1.1.tar.gz

Download URL ml3log-0.1.1.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
23e0fb15c80c2c4a8ec95bc9de438b92e85a7c349282b75685702f364248ceed
BLAKE2b-256 checksum
How to use checksums
7104c7c305391006be7689a00f169520a244e065e84397d12c6e1644c995d416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release files / ml3log-0.1.1-py3-none-any.whl

Download URL ml3log-0.1.1-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63fa9de6edc7e72a6d1503051f53b45ff2e9849af9c387844d2a99ee2f05c7c1
BLAKE2b-256 checksum
How to use checksums
270df056bc330e101238a3ebe144bc310f6bc8a60c0418c45ac096339c428415
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Security for ml3log 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page