Skip to main content

这是一高性能,多线程异步C++日志库的API包

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.3-cp311-cp311-win_amd64.whl (236.9 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

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

File metadata

  • Download URL: mxLogPy-0.1.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 236.9 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1c7f7ffe414f82ae00a0cb265bcd8bbe0866d8d3536666fc858dac9f03ced7f4
MD5 942981fc53cc7a26a49b43c31214231a
BLAKE2b-256 37b5163e1cd2a09d995b67e3e294e33d938cf2940a52f115073157dc374ee3c7

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