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 Distribution

mxlogpy-0.1.8.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

mxLogPy-0.1.8-cp311-cp311-win_amd64.whl (438.2 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file mxlogpy-0.1.8.tar.gz.

File metadata

  • Download URL: mxlogpy-0.1.8.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for mxlogpy-0.1.8.tar.gz
Algorithm Hash digest
SHA256 a41f2e60dd337d544e8f5dced9405d114790b7e0f571230b82fe7adbfaaae690
MD5 abb1ad86f63f757752591b9d99b3b0b9
BLAKE2b-256 05624788d4c309d3f1d47965d497e01779782067772379be7ce7ca0cae2a1aad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mxLogPy-0.1.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 438.2 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.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 da34c9581f801d92cd83a7d1bde85f6220c17087dfead5b80f20b3a1b6a060bf
MD5 49ea713edd77e3f8e4fbfb403c1f6ed0
BLAKE2b-256 6095761a184b88fc1404074880f779a103a22c3e48c252d879178aae6302be91

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