{ "info": { "author": "Martin Bammer", "author_email": "mrbm74@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "An efficient and feature-rich logging module\n============================================\n\n.. role:: Python(code)\n :language: Python\n\nThe ``fastlogging`` module is a faster replacement of the standard logging module with a mostly compatible API.\n\nIt comes with the following features:\n\n - (colored, if colorama is installed) logging to console\n - logging to file (maximum file size with rotating/history feature can be configured)\n - old log files can be compressed (the compression algorithm can be configured)\n - count same successive messages within a 30s time frame and log only once the message with the counted value.\n - log domains\n - log to different files\n - writing to log files is done in (per file) background threads, if configured\n - configure callback function for custom detection of same successive log messages\n - configure callback function for custom message formatter\n - configure callback function for custom log writer\n\nThe API is described `here `_.\n\nInstallation\n------------\n\nSimply run\n\n.. code-block:: Python\n\n python setup.py install --user\n\nor create a wheel and install it.\n\n.. code-block:: Python\n\n python setup.py bdist_wheel\n\nAn optimized version of ``fastlogging`` will be installed if package **cython** is installed.\nIf you need a pure python version of the ``fastlogging`` module then add option **nocython**.\n\nUsage\n-----\n\n.. code-block:: Python\n\n from fastlogging import LogInit\n\n logger = LogInit(pathName=\"/tmp/example1.log\", console=True, colors=True)\n logger.debug(\"This is a debug message.\")\n logger.info(\"This is an info message.\")\n logger.warning(\"This is a warning message.\")\n logger.rotate()\n logger.fatal(\"This is a fatal message.\")\n logger.shutdown()\n\nThe example above writes all messages to a file and to the console. On the console the messages are printed\nwith colors. With the rotate call the log file is renamed to `example1.log.1` and a new log file is created.\n\nThe second example creates a server socket on localhost and writes all messages to a log file for 15 seconds.\n\n.. code-block:: Python\n\n import os\n import time\n\n from fastlogging import LogInit\n\n addr = \"127.0.0.1\"\n port = 12345\n pathName = \"C:/temp/server.log\" if os.name == 'nt' else \"/tmp/server.log\"\n logger = LogInit(pathName=pathName, server=(addr, port))\n logger.info(\"Logging started.\")\n logger.debug(\"This is a debug message.\")\n logger.info(\"This is an info message.\")\n logger.warning(\"This is a warning message.\")\n time.sleep(15)\n logger.info(\"Shutdown logging.\")\n logger.shutdown()\n\n\nAnd now the third example connects to the log server and sends 300000 messages.\n\n.. code-block:: Python\n\n import os\n import time\n\n from fastlogging import LogInit\n\n addr = \"127.0.0.1\"\n port = 12345\n logger = LogInit(connect=(addr, port, \"HELLO%d\" % os.getpid()))\n for i in range(100000):\n logger.debug(\"This is a DBG message %d.\" % i)\n logger.info(\"This is an INF message %d.\" % i)\n logger.warning(\"This is a WRN message %d.\" % i)\n time.sleep(10.0)\n logger.shutdown()\n\nThe messages are sent in blocks to improve speed.\n\nOptimizing for speed\n--------------------\n\nAs you can see in the charts below fastlogging is much faster than the default logging module which comes\nwith Python (red bar).\n\nYou also can see that using threads can be slower than writing logs directly to the\nfile, because of additional overhead. So threads should only be used if you've got a slow disk and lot's of\nmessages to log.\n\nThere are 3 more bars which show even better performance. To understand the optimizations a deeper look into\na logging line has to be done.\n\nLet's analyze what is going on when the following code line is executed:\n\n.. code-block:: Python\n\n logger.debug(\"This is a debug message.\")\n\nThe Python interpreter first creates a tuple for the positioned arguments and a dictionary for the named\narguments. Then it calls method ``info``. In method ``info`` the log level is checked against the severity.\nOnly if the severity is high enough the message will be logged.\n\nNow what if we set a **if** before the above line?\n\n.. code-block:: Python\n\n if logger.level <= DEBUG:\n logger.debug(\"This is a debug message.\")\n\nRunning benchmarks will show us that the code runs faster now if the log level is higher than DEBUG.\nNormally we need debug messages only in case of development or bugfixing. So it makes sense to optimize\nsuch lines. But doing this manually is awkward and bloats the code.\n\nTo simplify this task the ``fastlogging`` module comes with an `AST optimizer `_ which does the work for you.\n\n\nBenchmarks\n----------\n\nThe following benchmarks were measured on Ubuntu 18.10 with a Ryzen 7 CPU and an SSD.\n\nYou can see that ``fastlogging`` is **~5x** faster when rotating is disabled and **>13x** faster in case of log rotating.\n\n\n\n.. figure:: doc/benchmarks/log.png\n\n Benchmark results with a single log files\n\n.. figure:: doc/benchmarks/rotate.png\n\n Benchmark results with rotating log files", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "https://github.com/brmmm3/fastlogging/releases/download/0.9.1/fastlogging-0.9.1.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brmmm3/fastlogging", "keywords": "fast logging", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "fastlogging", "package_url": "https://pypi.org/project/fastlogging/", "platform": "", "project_url": "https://pypi.org/project/fastlogging/", "project_urls": { "Download": "https://github.com/brmmm3/fastlogging/releases/download/0.9.1/fastlogging-0.9.1.tar.gz", "Homepage": "https://github.com/brmmm3/fastlogging" }, "release_url": "https://pypi.org/project/fastlogging/0.9.1/", "requires_dist": null, "requires_python": "", "summary": "A faster replacement of the standard logging module.", "version": "0.9.1" }, "last_serial": 5505676, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "92e328f77a1357281a2d42fe6db85695", "sha256": "50ac5c30276e5ca8d701041b6209707399992aadce94d6e174c116a0b26c8b7e" }, "downloads": -1, "filename": "fastlogging-0.9.0-py3-none-any.whl", "has_sig": false, "md5_digest": "92e328f77a1357281a2d42fe6db85695", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15583, "upload_time": "2019-01-08T11:19:44", "url": "https://files.pythonhosted.org/packages/ef/f4/bd4695bb0ef947c11be8e00a4b1e6681fe3418d6a3afb8166937e028afad/fastlogging-0.9.0-py3-none-any.whl" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "096a919009c5d345746f21c9316e57db", "sha256": "4f2521a8038598d3fa8a1913f8728e14d1a21a1058f823d2c63a9bf3b5a98b1e" }, "downloads": -1, "filename": "fastlogging-0.9.1.tar.gz", "has_sig": false, "md5_digest": "096a919009c5d345746f21c9316e57db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 274734, "upload_time": "2019-07-09T08:57:18", "url": "https://files.pythonhosted.org/packages/ce/28/92c4e9019dffd3067176246f419c5b4c3944fe3cd515df9c45c58d4649fe/fastlogging-0.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "096a919009c5d345746f21c9316e57db", "sha256": "4f2521a8038598d3fa8a1913f8728e14d1a21a1058f823d2c63a9bf3b5a98b1e" }, "downloads": -1, "filename": "fastlogging-0.9.1.tar.gz", "has_sig": false, "md5_digest": "096a919009c5d345746f21c9316e57db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 274734, "upload_time": "2019-07-09T08:57:18", "url": "https://files.pythonhosted.org/packages/ce/28/92c4e9019dffd3067176246f419c5b4c3944fe3cd515df9c45c58d4649fe/fastlogging-0.9.1.tar.gz" } ] }