Skip to main content

A super-simple tool for logging function execution time

Project description

English description follows Japanese.


概要

ticklog は、関数の実行時間を簡単にロギングできる Python ライブラリです。関数にデコレータをつけるだけで、その実行時間を自動的に記録します。

  • 軽量でシンプルな使い心地
  • llog ライブラリを使用して jsonl 形式でログ出力
  • デフォルトではカレントディレクトリに ticklog.llog を自動生成
  • ticklog.setpath() を使えば出力先のファイルパス変更も可能

主に、関数単位のパフォーマンス測定や簡易プロファイリングに適しています。


インストール

pip install ticklog

基本的な使い方

import time
import ticklog

@ticklog
def some_proc():
	time.sleep(0.5)

@ticklog
def other_proc():
	time.sleep(0.1)

some_proc()
other_proc()
some_proc()

このコードを実行すると、関数の実行時間が ticklog.llog というファイルに jsonl 形式で記録されます。関数が呼び出されるたびに、1行ずつログが追記されます。


ログの確認

最新のログを確認するには、以下のようにします:

ticklog.llog.tail(n = 3)

ログファイルの出力先を変更する

ticklog.setpath("other_path.llog")

以降のログ出力が other_path.llog に切り替わります。


Overview

ticklog is a minimalistic Python library for logging the execution time of functions. With just a simple decorator, you can measure and persist function runtimes in a structured format.

  • Super-lightweight and clean
  • Uses the llog library to write logs in jsonl format
  • By default, logs are saved to ticklog.llog in the current directory
  • You can also set a custom path for log output using ticklog.setpath()

This tool is especially suited for profiling and monitoring the performance of key functions during development or testing.


Installation

pip install ticklog

Basic Usage

import time
import ticklog

@ticklog
def some_proc():
	time.sleep(0.5)

@ticklog
def other_proc():
	time.sleep(0.1)

some_proc()
other_proc()
some_proc()

The above code will output the execution times of the decorated functions into a file named ticklog.llog (in JSONL format), using the llog logger.

Each time a decorated function is called, a log entry is appended.


Viewing Logs

To inspect the most recent log entries:

ticklog.llog.tail(n = 3)

Setting a Custom Log File Path

ticklog.setpath("other_path.llog")

This will redirect all future logs to the specified path.

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

ticklog-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

ticklog-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file ticklog-0.1.0.tar.gz.

File metadata

  • Download URL: ticklog-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for ticklog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 234d3b55a236f638da55905d2b7bdcc71921472570c67e2d40f3a5f6e641f490
MD5 a37d8ccc0d867711e1ddc44d5cfd60b8
BLAKE2b-256 f547989e9c9dbbda7cf776ce720a570819ce2f0703d2eff2b6b134b5c9585ab3

See more details on using hashes here.

File details

Details for the file ticklog-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ticklog-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for ticklog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be3243332890b58220ad0aaeda6beb0b0c34f90acd844fe0d85230828136272f
MD5 acd3809e9c40043d14094abe76cf828f
BLAKE2b-256 3dd9767508ecaa8b3ff51d75e45c6092accab61e463317374d8625faaa916cf8

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