Name | falcon-logger JSON |
Version |
1.1.8
JSON |
| download |
home_page | None |
Summary | module for faster python logging |
upload_time | 2025-07-13 00:52:29 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
logger
fast
cross-platform
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
* website: <https://arrizza.com/python-falcon-logger.html>
* installation: see <https://arrizza.com/setup-common.html>
## Summary
This is a python module that provides a way to run a fast logger.
Peregrine Falcons are the fastest animals alive (according to Google).
They go that fast by having as minimal drag as possible.
* See [Quick Start](https://arrizza.com/user-guide-quick-start) for information on using scripts.
* See [xplat-utils submodule](https://arrizza.com/xplat-utils) for information on the submodule.
## Sample code
see sample.py for a full example
```python
from falcon_logger import FalconLogger
```
## Sample
Use doit script to run the logger and compare against other loggers.
To run the FalconLogger:
```bash
./doit falcon
./doit falcon --numlines=100000 # saves to a file
./doit falcon2 --numlines=100000 # writes to stdout
./doit all --numlines=1 # prints a sample of all log line types
```
To run the other loggers:
```bash
./doit stdout # no file, just stdout
./doit normal # use the python logger
./doit rsyslog # use the rsyslog python module
```
## Comparing Times
The overall time is very dependent on which OS you use and the speed of your computer
```text
on MSYS2 for 100,000 lines:
stdout: total time: 3170.0 ms
falcon: total time: 3623.9 ms
normal: total time: 5722.8 ms
rsyslog fails with an exception
```
## parameters and functions
Use these on the logger creation: ```self._log = FalconLogger(path=etc, max_entries=etc, mode=etc.)```
* ```path=None``` : (default) write to stdout
* ```path='path/to/file'``` : write to the given file
* ```max_entries=10```: flush the queue when this number of log entries is reached.
* ```loop_delay=0.250```: check the queue this often. The longer the delay, the fast it runs.
* Note: use 1 and loop_delay=0.001, to flush the queue as often as possible
* ```set_verbose(True)``` - (default) print all log lines to stdout/file.
* ```set_verbose(False)``` - only print err(), critical(), exception(), and bug() lines
* ```self._log.set_max_dots()``` set the number of dots to print before a newline is printed
* use ```self._log.save() to force the queue to be saved. Generally not recommended.```
There are 3 modes: ```FalconLogger(mode='normal')```
* None or "normal": (default) writes a line to stdout or the file. See below for outputs
* 'ut' or 'mock': useful in UTs. These do not write to stdout or to a file.
* The lines are saved in an internal list accessible by: ```self._log.ut_lines```.
* Use ```self._log.ut_clear()``` or ```self._log.ut_lines = []``` to empty it.
* 'null': are useful when you don't want any output. No stdout, no file, no ut_lines.
There are 3 formats: elapsed (default), prefix, none
* Use ```self._log.set_format('elapsed')``` to set the format.
## "elapsed" format outputs
These contain:
* the number of MM:SS.nnn milliseconds since the last log line
* if this the first log line, the current date time stamp is automatically printed:
```DTS 2025/05/11 16:21:43.170```
* if an hour goes by since the last DTS, then it is automatically printed
* a prefix indicating the type of log line error, OK, Debug, etc.
```text
self._log.set_format('elapsed') # the default format
# i = 2
# === showing with elapsed time delays
# === self._log.start(f'{i}:', 'start')
# === time.sleep(0.250)
# === self._log.start(f'{i}:', 'start + 250ms')
# === time.sleep(0.123)
# === self._log.start(f'{i}:', 'start + 373ms')
00.000 ==== 2: start
00.250 ==== 2: start + 250ms
00.373 ==== 2: start + 373ms
# === the automatic DTS line when 1 hour has elapsed or at the beginning
# === self._log.start(f'{i}:', 'start')
DTS 2025/05/11 16:21:43.170
00.000 ==== 2: start
# === self._log.line(f'{i}:', 'line')
00.000 2: line
# === self._log.highlight(f'{i}:', 'highlight')
00.000 ---> 2: highlight
# === self._log.ok(f'{i}:', 'ok')
00.000 OK 2: ok
# === self._log.err(f'{i}:', 'err')
00.000 ERR 2: err
# === self._log.warn(f'{i}:', 'warn')
00.000 WARN 2: warn
# === self._log.bug(f'{i}:', 'bug')
00.000 BUG 2: bug
# === self._log.dbg(f'{i}:', 'dbg')
00.000 DBG 2: dbg
# === self._log.raw(f'{i}', 'raw', 'line')
2 raw line
# === self._log.output(21, f'{i}:', 'output (line 21)')
00.000 -- 21] 2: output (line 21)
# === lines = [f'{i}: num_output (line 1)', f'{i}: num_output (line 2)']
# === self._log.num_output(lines)
00.000 -- 1] 2: num_output (line 1)
00.000 -- 2] 2: num_output (line 2)
# === self._log.check(True, f'{i}:', 'check true')
00.000 OK 2: check true
# === self._log.check(False, f'{i}:', 'check false')
00.000 ERR 2: check false
# === lines = [f'{i}: check_all (line 1)', f'{i}: check_all (line 2)']
# === self._log.check_all(True, 'check_all true title', lines)
00.000 OK check_all true title: True
00.000 OK - 2: check_all (line 1)
00.000 OK - 2: check_all (line 2)
# === self._log.check_all(False, 'check_all false title', lines)
00.000 ERR check_all false title: False
00.000 ERR - 2: check_all (line 1)
00.000 ERR - 2: check_all (line 2)
# === info = {
# === 'key1': ['val1']
# === }
# === self._log.json(info, f'{i}:', 'json', 'list')
00.000 2: json list
00.000 > {
00.000 > "key1": [
00.000 > "val1"
00.000 > ]
00.000 > }
# === val = '\x12\x13\x14'
# === self._log.hex(val, f'{i}:', 'hex')
00.000 2: hex
00.000 0 0x00: 12 13 14
# === self._log.debug(f'{i}:', 'debug')
00.000 DBG 2: debug
# === self._log.info(f'{i}:', 'info')
00.000 2: info
# === self._log.warning(f'{i}:', 'warning')
00.000 WARN 2: warning
# === self._log.error(f'{i}:', 'error')
00.000 ERR 2: error
# === self._log.critical(f'{i}:', 'critical')
00.000 CRIT 2: critical
# === try:
# === val = 5
# === val = val / 0
# === except ZeroDivisionError as excp:
# === self._log.exception(excp)
00.000 EXCP Traceback (most recent call last):
00.000 EXCP File "/home/arrizza/projects/web/falcon-logger/sample/main.py", line 135, in _log_all
00.000 EXCP val = val / 0
00.000 EXCP ZeroDivisionError: division by zero
self._log.full_dts()
DTS 2025/05/11 16:21:43.170
```
## "prefix" format outputs
These are the same as elapsed format, except no elapsed times.
```text
self._log.set_format('prefix')
# === self._log.ok(f'{i}:', 'ok')
OK 2: ok
# === self._log.err(f'{i}:', 'err')
ERR 2: err
<snip>
```
## "none" format outputs
These are the same as elapsed/prefix format, except no elapsed times or prefixes
```text
self._log.set_format('none')
# === self._log.ok(f'{i}:', 'ok')
2: ok
# === self._log.err(f'{i}:', 'err')
2: err
<snip>
```
Raw data
{
"_id": null,
"home_page": null,
"name": "falcon-logger",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "\"J. Arrizza\" <cppgent0@gmail.com>",
"keywords": "logger, fast, cross-platform",
"author": null,
"author_email": "\"J. Arrizza\" <cppgent0@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/4f/82/85596d2520a6aa5fcda229d319f1c5f5a049ce7cc61dbb89fdfc0c026cf5/falcon_logger-1.1.8.tar.gz",
"platform": null,
"description": "* website: <https://arrizza.com/python-falcon-logger.html>\n* installation: see <https://arrizza.com/setup-common.html>\n\n## Summary\n\nThis is a python module that provides a way to run a fast logger.\nPeregrine Falcons are the fastest animals alive (according to Google).\nThey go that fast by having as minimal drag as possible.\n\n* See [Quick Start](https://arrizza.com/user-guide-quick-start) for information on using scripts.\n* See [xplat-utils submodule](https://arrizza.com/xplat-utils) for information on the submodule.\n\n## Sample code\n\nsee sample.py for a full example\n\n```python\nfrom falcon_logger import FalconLogger\n```\n\n## Sample\n\nUse doit script to run the logger and compare against other loggers.\n\nTo run the FalconLogger:\n\n```bash\n./doit falcon\n./doit falcon --numlines=100000 # saves to a file\n./doit falcon2 --numlines=100000 # writes to stdout \n./doit all --numlines=1 # prints a sample of all log line types\n```\n\nTo run the other loggers:\n\n```bash\n./doit stdout # no file, just stdout\n./doit normal # use the python logger\n./doit rsyslog # use the rsyslog python module\n```\n\n## Comparing Times\n\nThe overall time is very dependent on which OS you use and the speed of your computer\n\n```text\non MSYS2 for 100,000 lines:\nstdout: total time: 3170.0 ms\nfalcon: total time: 3623.9 ms\nnormal: total time: 5722.8 ms\nrsyslog fails with an exception \n```\n\n## parameters and functions\n\nUse these on the logger creation: ```self._log = FalconLogger(path=etc, max_entries=etc, mode=etc.)```\n\n* ```path=None``` : (default) write to stdout\n* ```path='path/to/file'``` : write to the given file\n* ```max_entries=10```: flush the queue when this number of log entries is reached.\n* ```loop_delay=0.250```: check the queue this often. The longer the delay, the fast it runs.\n* Note: use 1 and loop_delay=0.001, to flush the queue as often as possible\n\n* ```set_verbose(True)``` - (default) print all log lines to stdout/file.\n* ```set_verbose(False)``` - only print err(), critical(), exception(), and bug() lines\n* ```self._log.set_max_dots()``` set the number of dots to print before a newline is printed\n* use ```self._log.save() to force the queue to be saved. Generally not recommended.```\n\nThere are 3 modes: ```FalconLogger(mode='normal')```\n\n* None or \"normal\": (default) writes a line to stdout or the file. See below for outputs\n* 'ut' or 'mock': useful in UTs. These do not write to stdout or to a file.\n * The lines are saved in an internal list accessible by: ```self._log.ut_lines```.\n * Use ```self._log.ut_clear()``` or ```self._log.ut_lines = []``` to empty it.\n* 'null': are useful when you don't want any output. No stdout, no file, no ut_lines.\n\nThere are 3 formats: elapsed (default), prefix, none\n\n* Use ```self._log.set_format('elapsed')``` to set the format.\n\n## \"elapsed\" format outputs\n\nThese contain:\n\n* the number of MM:SS.nnn milliseconds since the last log line\n * if this the first log line, the current date time stamp is automatically printed:\n ```DTS 2025/05/11 16:21:43.170```\n * if an hour goes by since the last DTS, then it is automatically printed\n* a prefix indicating the type of log line error, OK, Debug, etc.\n\n```text\nself._log.set_format('elapsed') # the default format\n\n# i = 2\n\n# === showing with elapsed time delays \n# === self._log.start(f'{i}:', 'start')\n# === time.sleep(0.250)\n# === self._log.start(f'{i}:', 'start + 250ms')\n# === time.sleep(0.123)\n# === self._log.start(f'{i}:', 'start + 373ms')\n00.000 ==== 2: start\n00.250 ==== 2: start + 250ms\n00.373 ==== 2: start + 373ms\n\n# === the automatic DTS line when 1 hour has elapsed or at the beginning\n# === self._log.start(f'{i}:', 'start')\n DTS 2025/05/11 16:21:43.170\n00.000 ==== 2: start\n\n# === self._log.line(f'{i}:', 'line')\n00.000 2: line\n\n# === self._log.highlight(f'{i}:', 'highlight')\n00.000 ---> 2: highlight\n\n# === self._log.ok(f'{i}:', 'ok')\n00.000 OK 2: ok\n\n# === self._log.err(f'{i}:', 'err')\n00.000 ERR 2: err\n\n# === self._log.warn(f'{i}:', 'warn')\n00.000 WARN 2: warn\n\n# === self._log.bug(f'{i}:', 'bug')\n00.000 BUG 2: bug\n\n# === self._log.dbg(f'{i}:', 'dbg')\n00.000 DBG 2: dbg\n\n# === self._log.raw(f'{i}', 'raw', 'line')\n2 raw line\n\n# === self._log.output(21, f'{i}:', 'output (line 21)')\n00.000 -- 21] 2: output (line 21)\n\n# === lines = [f'{i}: num_output (line 1)', f'{i}: num_output (line 2)']\n# === self._log.num_output(lines)\n00.000 -- 1] 2: num_output (line 1)\n00.000 -- 2] 2: num_output (line 2)\n\n# === self._log.check(True, f'{i}:', 'check true')\n00.000 OK 2: check true\n\n# === self._log.check(False, f'{i}:', 'check false')\n00.000 ERR 2: check false\n\n# === lines = [f'{i}: check_all (line 1)', f'{i}: check_all (line 2)']\n# === self._log.check_all(True, 'check_all true title', lines)\n00.000 OK check_all true title: True\n00.000 OK - 2: check_all (line 1)\n00.000 OK - 2: check_all (line 2)\n\n# === self._log.check_all(False, 'check_all false title', lines)\n00.000 ERR check_all false title: False\n00.000 ERR - 2: check_all (line 1)\n00.000 ERR - 2: check_all (line 2)\n\n# === info = {\n# === 'key1': ['val1']\n# === }\n# === self._log.json(info, f'{i}:', 'json', 'list')\n00.000 2: json list\n00.000 > {\n00.000 > \"key1\": [\n00.000 > \"val1\"\n00.000 > ]\n00.000 > }\n\n# === val = '\\x12\\x13\\x14'\n# === self._log.hex(val, f'{i}:', 'hex')\n00.000 2: hex\n00.000 0 0x00: 12 13 14 \n\n# === self._log.debug(f'{i}:', 'debug')\n00.000 DBG 2: debug\n\n# === self._log.info(f'{i}:', 'info')\n00.000 2: info\n\n# === self._log.warning(f'{i}:', 'warning')\n00.000 WARN 2: warning\n\n# === self._log.error(f'{i}:', 'error')\n00.000 ERR 2: error\n\n# === self._log.critical(f'{i}:', 'critical')\n00.000 CRIT 2: critical\n\n# === try:\n# === val = 5\n# === val = val / 0\n# === except ZeroDivisionError as excp:\n# === self._log.exception(excp)\n00.000 EXCP Traceback (most recent call last):\n00.000 EXCP File \"/home/arrizza/projects/web/falcon-logger/sample/main.py\", line 135, in _log_all\n00.000 EXCP val = val / 0\n00.000 EXCP ZeroDivisionError: division by zero\n\nself._log.full_dts()\n DTS 2025/05/11 16:21:43.170\n```\n\n## \"prefix\" format outputs\n\nThese are the same as elapsed format, except no elapsed times.\n\n```text\nself._log.set_format('prefix')\n\n# === self._log.ok(f'{i}:', 'ok')\nOK 2: ok\n# === self._log.err(f'{i}:', 'err')\nERR 2: err\n<snip>\n```\n\n## \"none\" format outputs\n\nThese are the same as elapsed/prefix format, except no elapsed times or prefixes\n\n```text\nself._log.set_format('none')\n\n# === self._log.ok(f'{i}:', 'ok')\n2: ok\n# === self._log.err(f'{i}:', 'err')\n2: err\n<snip>\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "module for faster python logging",
"version": "1.1.8",
"project_urls": {
"Download": "https://bitbucket.org/arrizza-public/falcon-logger/get/master.zip",
"Source": "https://bitbucket.org/arrizza-public/falcon-logger/src/master",
"Website": "https://arrizza.com/python-falcon-logger"
},
"split_keywords": [
"logger",
" fast",
" cross-platform"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4f8285596d2520a6aa5fcda229d319f1c5f5a049ce7cc61dbb89fdfc0c026cf5",
"md5": "7337790f11911d4d4c4a8732d3bd0af5",
"sha256": "8391b130f754b99e735f5399ab66e885657c34e753cfd93253d93e424a6f007d"
},
"downloads": -1,
"filename": "falcon_logger-1.1.8.tar.gz",
"has_sig": false,
"md5_digest": "7337790f11911d4d4c4a8732d3bd0af5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 13803,
"upload_time": "2025-07-13T00:52:29",
"upload_time_iso_8601": "2025-07-13T00:52:29.002168Z",
"url": "https://files.pythonhosted.org/packages/4f/82/85596d2520a6aa5fcda229d319f1c5f5a049ce7cc61dbb89fdfc0c026cf5/falcon_logger-1.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-13 00:52:29",
"github": false,
"gitlab": false,
"bitbucket": true,
"codeberg": false,
"bitbucket_user": "arrizza-public",
"bitbucket_project": "falcon-logger",
"lcname": "falcon-logger"
}