Skip to main content

A package for atomic evaluation tools and utilities

Project description

Core features

Log data as tables, and then render them as entries in web log viewer with extremely simple functions !

from best_logger import *

# === log nested dictionaries as table ===
print_dictofdict({
    'sample-1':{
        "a": 1,
        "b": 2,
        "c": 3,
    },
    'sample-2':{
        "a": 4,
        "b": 5,
        "c": 6,
    }
}, narrow=True, header="this is a header", mod="", attach="create a copy button in web log viewer, when clicked, copy this message into clipboard")

# ╭─────────────── this is a header ───────────────╮
# │ ┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┓ │
# │ ┃                      ┃ a     ┃ b    ┃ c    ┃ │
# │ ┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━┩ │
# │ │ sample-1             │ 1     │ 2    │ 3    │ │
# │ ├──────────────────────┼───────┼──────┼──────┤ │
# │ │ sample-2             │ 4     │ 5    │ 6    │ │
# │ └──────────────────────┴───────┴──────┴──────┘ │
# ╰────────────────────────────────────────────────╯

Image

# === log a list of dictionaries as table ===
print_listofdict(
    [{
        "a": 1,
        "b": 2,
        "c": 3,
    },
    {
        "a": 4,
        "b": 5,
        "c": 6,
    }], narrow=True)

# ╭────────────────────────────────────────────────╮
# │ ┏━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┓ │
# │ ┃           ┃ a        ┃ b        ┃ c        ┃ │
# │ ┡━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━┩ │
# │ │ 0         │ 1        │ 2        │ 3        │ │
# │ ├───────────┼──────────┼──────────┼──────────┤ │
# │ │ 1         │ 4        │ 5        │ 6        │ │
# │ └───────────┴──────────┴──────────┴──────────┘ │
# ╰────────────────────────────────────────────────╯
# === log dictionary as table ===
print_dict({
    "a": 1,
    "b": 2,
    "c": 3,
}, mod="abc")

# ╭────────────────────────────────────────────────╮
# │ ┌──────────────────────┬─────────────────────┐ │
# │ │ a                    │ 1                   │ │
# │ ├──────────────────────┼─────────────────────┤ │
# │ │ b                    │ 2                   │ │
# │ ├──────────────────────┼─────────────────────┤ │
# │ │ c                    │ 3                   │ │
# │ └──────────────────────┴─────────────────────┘ │
# ╰────────────────────────────────────────────────╯

Quick Start

  • install: pip install beast-logger -i https://pypi.org/simple

  • import

    from best_logger import *
    
  • register file handler

    def register_logger(mods=[], non_console_mods=[], base_log_path="logs", auto_clean_mods=[]):
        """ mods: 需要注册的模块名列表,同时向终端和文件输出
            non_console_mods: 需要注册的模块名列表,只向文件输出
            base_log_path: 日志文件存放的根目录
            auto_clean_mods: 需要自动删除旧日志的模块名列表
    """
    
  • begin logging

    from best_logger import *
    register_logger(mods=["abc"])
    print_dict({
        "a": 1,
        "b": 2,
        "c": 3,
    }, mod="abc")
    
  • install nvm

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

  • launch web display on port 8181 (first time)

    python -m web_display.install 8181

  • launch web display on port 8181 (skip npm install)

    python -m web_display.go 8181

  • open in browser

    http://localhost:8181

Image

  • test program and enter log dir (absolute path) into web log viewer.
    from best_logger import *
    register_logger(mods=["abc"])
    print_dict({
        "a": 1,
        "b": 2,
        "c": 3,
    }, mod="abc")
    

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

beast_logger-0.0.3.tar.gz (585.7 kB view details)

Uploaded Source

Built Distribution

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

beast_logger-0.0.3-py3-none-any.whl (592.5 kB view details)

Uploaded Python 3

File details

Details for the file beast_logger-0.0.3.tar.gz.

File metadata

  • Download URL: beast_logger-0.0.3.tar.gz
  • Upload date:
  • Size: 585.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for beast_logger-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3db64d1bf8e4bf071450f041f43f0af861b90b8a561ff6a9c1e1f76f3efa4ce2
MD5 b805752b60b391dd978c86649ce48b9a
BLAKE2b-256 b0fdc2d9a943debd196ac65ee1a17c80decbfeb661c093678f5ed7d0be870832

See more details on using hashes here.

File details

Details for the file beast_logger-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: beast_logger-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 592.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for beast_logger-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d1aa8903f2f92f6f40ca232203a6069adb01c5692171f37f360b50380ff44446
MD5 841d446724f6a7a79fb079ed3032b888
BLAKE2b-256 7e4f709523346b4ca0e09568b6332ad65c7c617f366aa88dd393507cdbc6bce9

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