Skip to main content

A super-simple tool for logging function execution time

Project description

English description follows Japanese.


概要

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

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

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


インストール

pip install log_time

基本的な使い方

import time
import log_time

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

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

some_proc()
other_proc()
some_proc()

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


ログの確認

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

log_time.llog.tail(n = 3)

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

log_time.setpath("other_path.llog")

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


Overview

log_time 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 timelog.llog in the current directory
  • You can also set a custom path for log output using log_time.setpath()

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


Installation

pip install log_time

Basic Usage

import time
import log_time

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

@log_time
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 timelog.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:

log_time.llog.tail(n = 3)

Setting a Custom Log File Path

log_time.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.0.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.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ticklog-0.0.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.0.0.tar.gz
Algorithm Hash digest
SHA256 1322f2644ae1af5f69bb331af4801d2c65fa4c3115760552b78df010843645e0
MD5 5eda57401347c749a3d53f4c26ce0535
BLAKE2b-256 974579d682062d1bf62d67051f57fad9efe2b869790a4d384e06a2877e3f13be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ticklog-0.0.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b21089df46495e5abbf304471eda514d72d514b96d43ba3fbd1acf47968dd208
MD5 d947eb01750906d96e11645893100eb8
BLAKE2b-256 f5baca8a06c7f399897b3d9e0cf119869a1a30e6f93cf109278283904a5e4096

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