Skip to main content

High Performance and mutilThread & async Log Library by Cpp

Project description

使用案例

import sys
import mxLogPy as mxLog
import time


def manual_test():
    # 获取 LogManager 单例实例
    logger = mxLog.LogManager.getInstance()
    # 设置文件追加器
    logger.setFileAppender("logAuto.txt")
    # 设置控制台追加器
    logger.setConsoleAppender()

    logger.setOutBufferSize(10)
    logger.setBufferSize(10)
    # 测试消息
    logger.log("Info", mxLog.LogLevel.Info)
    logger.log("Debug", mxLog.LogLevel.Debug)
    logger.log("Info", mxLog.LogLevel.Info)
    logger.log("Warning", mxLog.LogLevel.Warning)
    logger.log("Error", mxLog.LogLevel.Error)
    logger.log("Fatal", mxLog.LogLevel.Fatal)
    logger.clearConsoleBuffer()
    time.sleep(1)


def benchMark():
    # 获取 LogManager 单例实例
    logger = mxLog.LogManager.getInstance()

    # 设置文件追加器
    logger.setFileAppender("benchmark.txt")
    # 设置控制台追加器
    logger.setConsoleAppender()

    # 设置输出缓冲区大小
    logger.setOutBufferSize(1000)

    # 记录开始时间
    start = time.time()

    # 进行十万次 info 输入
    for i in range(20000):
        logger.log("Info :" + str(i), mxLog.LogLevel.Info)
        logger.log("Debug :" + str(i), mxLog.LogLevel.Debug)
        logger.log("Warning :" + str(i), mxLog.LogLevel.Warning)
        logger.log("Error :" + str(i), mxLog.LogLevel.Error)
        logger.log("Fatal :" + str(i), mxLog.LogLevel.Fatal)
        if i == 20000:
            logger.clearConsoleBuffer()

    # 记录结束时间
    end = time.time()

    # 计算耗时
    elapsed_time = end - start

    # 记录耗时到日志
    logger.log(f"Elapsed time: {elapsed_time:.6f} seconds", mxLog.LogLevel.Info)


if __name__ == "__main__":
    manual_test()
    # benchMark()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

mxLogPy-0.1.4-cp311-cp311-win_amd64.whl (437.3 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file mxLogPy-0.1.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mxLogPy-0.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 437.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for mxLogPy-0.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 810f9186afc72a7bf29b3d3f16ebf0b074467e1be5a341a88ad29cd1b52079a8
MD5 77a4adab425ace4ebb5e08ccbf7a8c32
BLAKE2b-256 ba543413d916e8667c5615f0b8ad78afeeba521b7bf6026545681b6ddf16d2c9

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