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.setLoggerName('mxLogger')
    # 测试消息
    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.9.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.9-cp311-cp311-win_amd64.whl (438.3 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

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

File metadata

  • Download URL: mxlogpy-0.1.9.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.9.tar.gz
Algorithm Hash digest
SHA256 cd614f3bd0029be40382a3b038094eafde9b28bf4e200f7b95649efc74704557
MD5 5a24f80b0c262f09a0f2d3b8b19e5fa8
BLAKE2b-256 4e6b043d048327f5649c7133357e32f264ec90557c32b92df2ed52d1d94879dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mxLogPy-0.1.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 438.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.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dab3cbdc2b786367d0832f4c61896d00136a9110017512ace3e7e92334afd20a
MD5 e4943625098262e1b9e76d2c0b86f203
BLAKE2b-256 afc8408bd66cc65197d4f56f69275473bf49e4295d8029a47537d57eeddd6f58

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