Skip to main content

A zero-dependency single-file logging library.

Project description

10 languages Zero deps License Copy paste

🐞 LogX

One file. Ten languages. Zero dependencies.
Copy. Paste. Log.


What if logging were this easy?

from logx import info, warn, error

info("Server started on port %d", 8080)
warn("Memory at %.1f%%", 74.2)
error("Connection lost")
LOGX_INFO("Server started on port %d", 8080);
LOGX_WARN("Memory at %.1f%%", 74.2);
LOGX_ERROR("Connection lost");
logx_info!("Server started on port {}", 8080);
logx_warn!("Memory at {:.1}%", 74.2);
logx_error!("Connection lost");

That's it. No installs. No config files. No npm install hunting down 200 transitive deps.


Why LogX?

Logging should be as easy as print(). But print() doesn't give you levels, timestamps, colors, or file output.

Most logging libraries give you all that — and also give you a headache. Setup, configuration, dependencies, framework lock-in...

LogX is the opposite. One file per language. Same API philosophy everywhere. Drop it in, include it, done.

Why not just print()?

Feature print() LogX
Log levels ✅ TRACE, INFO, WARN, ERROR, FATAL
Timestamps [HH:MM:SS.mmm]
File & line ✅ Automatic
Colored output ✅ Auto TTY detection
File logging ✅ Optional, one call
Thread safe ✅ Mutex-guarded
Level filtering LOG_LEVEL=WARN ./app
Still one file

Quick Start

Language File Include
Python python/logx.py from logx import info
JavaScript js/logx.js const { info } = require('./logx')
TypeScript ts/logx.ts import { info } from './logx'
C c/logx.h #include "logx.h"LOGX_INFO(...)
C++ cpp/logx.h #include "logx.h"LOGX_INFO << ...
Rust rust/logx.rs #[macro_use] mod logx;logx_info!(...)
Go go/logx.go import "yourmodule/logx"logx.Info(...)
Java java/logx.java import Logx;Logx.info(...)
Zig zig/logx.zig @import("logx.zig")logx.log(.info, ...)
Assembly asm/logx.asm %include "logx.asm"log_info "..."

Python

from logx import trace, info, warn, error, fatal, set_log_file

info("hello %d", 42)
error("something broke")

set_log_file("/tmp/app.log")  # redirect to file

JavaScript (Node)

const { trace, info, warn, error, fatal, setLogFile } = require('./logx');

info('hello %d', 42);
error('something broke');

TypeScript

import { trace, info, warn, error, fatal, setLogFile } from './logx';

info('hello %d', 42);
error('something broke');

C

#include "logx.h"

int main() {
    LOGX_INFO("hello %d", 42);
    LOGX_ERROR("something broke");
}
// Optional: log to file
lx_set_log_file("/tmp/app.log");
gcc -std=c11 main.c -o app -lpthread

C++

#include "logx.h"

int main() {
    LOGX_INFO << "hello " << 42;
    LOGX_ERROR << "something broke";
}
// Optional: log to file
Logx::setLogFile("/tmp/app.log");
Logx::setLogFile();  // back to terminal
g++ -std=c++11 main.cpp -o app

Rust

#[macro_use] mod logx;

fn main() {
    logx_info!("hello {}", 42);
    logx_error!("something broke");
}
// Optional: log to file
logx::set_log_file("/tmp/app.log");
[dependencies]
libc = "0.2"

Go

package main

import "yourmodule/logx"

func main() {
    logx.Info("hello %d", 42)
    logx.Error("something broke")
}
// Optional: log to file
logx.SetLogFile("/tmp/app.log")

Java

public class Main {
    public static void main(String[] args) {
        Logx.info("hello %d", 42);
        Logx.error("something broke");
    }
}
// Optional: log to file
Logx.setLogFile("/tmp/app.log");
javac Logx.java Main.java && java Main

Zig

const logx = @import("logx.zig");

pub fn main() void {
    logx.log(.info, "hello 42", @src());
    logx.log(.error, "something broke", @src());
}
// Optional: log to file
try logx.setLogFile("/tmp/app.log");

x86-64 Assembly (Linux, NASM)

%include "logx.asm"

section .data
log_str(msg_hello, "hello 42")
log_str(msg_error, "something broke")

section .text
global _start
_start:
    call log_init
    log_info msg_hello
    log_error msg_error
    call log_close

    mov rax, 60
    xor rdi, rdi
    syscall
; Optional: log to file (define before including)
%define LOG_FILE_PATH "/tmp/app.log"
%include "logx.asm"
nasm -felf64 main.asm -o main.o && ld main.o -o main

Environment Variables

Variable Values Default
LOG_LEVEL TRACE, INFO, WARN, ERROR, FATAL TRACE
LOG_COLOR 0, 1, yes Auto (enabled if both stdout/stderr are TTYs)

Output Format

[HH:MM:SS.mmm][LEVEL] filename:line -> message

Philosophy

LogX is not trying to replace OpenTelemetry. It is built for:

  • Prototypes & hackathons
  • CLI tools & scripts
  • Game jams
  • Students learning a new language
  • Small-to-medium projects
  • Anyone who just wants to log without ceremony

"If you can write print(), you already know how to use LogX."

License

BSD 2-Clause. See 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

py_logn-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

py_logn-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file py_logn-1.0.0.tar.gz.

File metadata

  • Download URL: py_logn-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py_logn-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fd7b380b87a5b4d6b0c996589ff8a70835a03b8ee30c5591b43c45056e02c9d0
MD5 3f2549450872e270df90f5f9966aca57
BLAKE2b-256 3ae2ad27d823615902f30421e23f98ac5223e6b8ad2a257b95f2f8220d6c0f97

See more details on using hashes here.

File details

Details for the file py_logn-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_logn-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for py_logn-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7271666d4b3065771496a61c768afae79dd49a9a084353351604519e96ca0002
MD5 b660a3e8a86fa0a94aea2169c9fa275c
BLAKE2b-256 8c15ef15e8eeb71865649562b6b56b0318bb13b4dc40a172253348c40f9e47ba

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