# SeqPyLogger
[](https://pypi.org/project/seqpylogger/)
SeqPyLogger is a python loghandler for [seq](https://datalust.co/seq).
## Usage
```python
import os
os.environ["SEQ_APIKEY"] = "xSxExQxAxPxIxKxExYx"
os.environ["SEQ_SERVER"] = "http://localhost:8794/"
os.environ["Environment"] = "Staging"
import logging
from seqpylogger import SeqPyLogger
root = logging.getLogger()
root.setLevel(logging.INFO)
seqLogger = SeqPyLogger(buffer_capacity=10)
root.addHandler(seqLogger)
logger = logging.getLogger("MyLogger")
logger.debug("Debug log message")
logger.info("Informational log message")
logger.warning("Warning log message")
logger.error("Error log message")
logger.critical("Critical log message")
logger.fatal("Critical log message")
logger.info("Test log message with argument %s", "dummy argument")
logger.info("Test log message with arguments %s, %s", "dummy argument 1", "dummy argument 2")
try:
raise Exception("Some issue")
except:
logging.exception("An error occured but now we have the stacktrace")
# logging.error("There was an error", exc_info=1) # alternative to .exception()
# logs are flushed every 10 seconds and every 10 logs
```
An alternative way of setting the handler is using the dictConfig
```python
import os
import time
import logging
import logging.config
os.environ["SEQ_APIKEY"] = "xSxExQxAxPxIxKxExYx"
os.environ["SEQ_SERVER"] = "http://localhost:8794/"
os.environ["Environment"] = "Staging"
logger_config = {
"version": 1,
"disable_existing_loggers": True,
"root": {
"level": logging.INFO,
"handlers": ["seq"]
},
"handlers": {
"seq": {
"level": logging.INFO,
"class": "seqpylogger.SeqPyLogger"
},
},
}
logging.config.dictConfig(logger_config)
logging.info("Example message")
```
## Installation
```bash
pip install seqpylogger
```
## Test install
Used for development on the package.
```bash
sudo python3 -m pip install -U .
```
## Examples
```python
try:
raise Exception("Some issue")
except:
logging.exception("An error occured but now we have the stacktrace")
# logging.error("There was an error", exc_info=1) # alternative to .exception()
try:
raise Exception("Some issue")
except:
logging.fatal("This time no stacktrace")
try:
raise Exception("Some issue")
except:
logging.fatal("Stacktrace is not limited to ERROR", exc_info=1)
```
## Images

# Changelog
inspired by [Keep a changelog](https://keepachangelog.com/en/1.0.0/)
## [2024-08-15]
- [Added] object serialization support
- [Added] fallback parse when parsing fails
## [2024-07-16]
- [Added] allow for extra named attributes
- [Changed] ENVIRONMENT with capital letters will be recognized first
## [2023-02-15]
- [Fixed] Formatting using `%d` broke the internal formatter
## [2023-01-08]
- [Fixed] Update dependencies in Pipfile.lock
- [Added] Tests for basic usage (added script `pipenv run tests`)
## [2021-08-20]
- [Fixed] Version file removed as this broke pip installation
- ~~[Fixed] Missing .version file in MANIFEST.md broke pip installation~~
## [2021-08-13]
- [Fixed] Replaced badge.fury.io pypi badge with shields.io
- [Changed] Added tagging in create_release.sh
- [Changed] Used `atexit` to register flush on exit
- [Fixed] Fixed issue of duplicate logs when doing a manualflush
## [2021-03-22]
- [Fixed] Update dependencies in Pipfile.lock
## [2020-12-29]
- [Fixed] old dependencies for development
## [2020-07-17]
- [Fixed] .msg and arg objects always converted to str
- [Changed] internal logs nolonger use root logger
## [2020-05-13]
- [Fixed] Removed print line when adding seq url without trailing slash
- [Changed] README example to fully work if copied
- [Added] changelog to README
## [Unreleased]
- Environment variable only works using `Environment` while full uppercase is the best practice for environment variables
- `logger.info("", extra={})` parameters are not shown in seq
Raw data
{
"_id": null,
"home_page": "https://github.com/wearetriple/seqpylogger",
"name": "seqpylogger",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Triple",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0b/8f/a79865a8f3f7ee2164b6724756bf44a934ca8024edeaba228460ce962e34/seqpylogger-1.1.1.tar.gz",
"platform": null,
"description": "# SeqPyLogger\r\n\r\n[](https://pypi.org/project/seqpylogger/)\r\n\r\nSeqPyLogger is a python loghandler for [seq](https://datalust.co/seq).\r\n\r\n## Usage\r\n\r\n```python\r\nimport os\r\n\r\nos.environ[\"SEQ_APIKEY\"] = \"xSxExQxAxPxIxKxExYx\"\r\nos.environ[\"SEQ_SERVER\"] = \"http://localhost:8794/\"\r\nos.environ[\"Environment\"] = \"Staging\"\r\n\r\nimport logging\r\nfrom seqpylogger import SeqPyLogger\r\n\r\nroot = logging.getLogger()\r\nroot.setLevel(logging.INFO)\r\nseqLogger = SeqPyLogger(buffer_capacity=10)\r\nroot.addHandler(seqLogger)\r\n\r\nlogger = logging.getLogger(\"MyLogger\")\r\n\r\nlogger.debug(\"Debug log message\")\r\nlogger.info(\"Informational log message\")\r\nlogger.warning(\"Warning log message\")\r\nlogger.error(\"Error log message\")\r\nlogger.critical(\"Critical log message\")\r\nlogger.fatal(\"Critical log message\")\r\n\r\nlogger.info(\"Test log message with argument %s\", \"dummy argument\")\r\nlogger.info(\"Test log message with arguments %s, %s\", \"dummy argument 1\", \"dummy argument 2\")\r\n\r\ntry:\r\n raise Exception(\"Some issue\")\r\nexcept:\r\n logging.exception(\"An error occured but now we have the stacktrace\")\r\n # logging.error(\"There was an error\", exc_info=1) # alternative to .exception()\r\n\r\n# logs are flushed every 10 seconds and every 10 logs\r\n```\r\n\r\nAn alternative way of setting the handler is using the dictConfig\r\n\r\n```python\r\nimport os\r\nimport time\r\nimport logging\r\nimport logging.config\r\n\r\nos.environ[\"SEQ_APIKEY\"] = \"xSxExQxAxPxIxKxExYx\"\r\nos.environ[\"SEQ_SERVER\"] = \"http://localhost:8794/\"\r\nos.environ[\"Environment\"] = \"Staging\"\r\n\r\nlogger_config = {\r\n \"version\": 1,\r\n \"disable_existing_loggers\": True,\r\n \"root\": {\r\n \"level\": logging.INFO,\r\n \"handlers\": [\"seq\"]\r\n },\r\n \"handlers\": {\r\n \"seq\": {\r\n \"level\": logging.INFO,\r\n \"class\": \"seqpylogger.SeqPyLogger\"\r\n },\r\n },\r\n}\r\n\r\nlogging.config.dictConfig(logger_config)\r\n\r\nlogging.info(\"Example message\")\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\npip install seqpylogger\r\n```\r\n\r\n## Test install\r\n\r\nUsed for development on the package.\r\n\r\n```bash\r\nsudo python3 -m pip install -U .\r\n```\r\n\r\n## Examples\r\n\r\n```python\r\ntry:\r\n raise Exception(\"Some issue\")\r\nexcept:\r\n logging.exception(\"An error occured but now we have the stacktrace\")\r\n # logging.error(\"There was an error\", exc_info=1) # alternative to .exception()\r\n\r\ntry:\r\n raise Exception(\"Some issue\")\r\nexcept:\r\n logging.fatal(\"This time no stacktrace\")\r\n\r\ntry:\r\n raise Exception(\"Some issue\")\r\nexcept:\r\n logging.fatal(\"Stacktrace is not limited to ERROR\", exc_info=1)\r\n```\r\n\r\n## Images\r\n\r\n\r\n\r\n# Changelog\r\n\r\ninspired by [Keep a changelog](https://keepachangelog.com/en/1.0.0/)\r\n\r\n## [2024-08-15]\r\n- [Added] object serialization support\r\n- [Added] fallback parse when parsing fails\r\n\r\n## [2024-07-16]\r\n- [Added] allow for extra named attributes\r\n- [Changed] ENVIRONMENT with capital letters will be recognized first\r\n\r\n## [2023-02-15]\r\n- [Fixed] Formatting using `%d` broke the internal formatter\r\n\r\n## [2023-01-08]\r\n- [Fixed] Update dependencies in Pipfile.lock\r\n- [Added] Tests for basic usage (added script `pipenv run tests`)\r\n\r\n## [2021-08-20]\r\n- [Fixed] Version file removed as this broke pip installation\r\n- ~~[Fixed] Missing .version file in MANIFEST.md broke pip installation~~\r\n\r\n## [2021-08-13]\r\n- [Fixed] Replaced badge.fury.io pypi badge with shields.io\r\n- [Changed] Added tagging in create_release.sh\r\n- [Changed] Used `atexit` to register flush on exit\r\n- [Fixed] Fixed issue of duplicate logs when doing a manualflush\r\n\r\n## [2021-03-22]\r\n- [Fixed] Update dependencies in Pipfile.lock\r\n\r\n## [2020-12-29]\r\n- [Fixed] old dependencies for development\r\n\r\n## [2020-07-17]\r\n- [Fixed] .msg and arg objects always converted to str\r\n- [Changed] internal logs nolonger use root logger\r\n\r\n## [2020-05-13]\r\n- [Fixed] Removed print line when adding seq url without trailing slash\r\n- [Changed] README example to fully work if copied\r\n- [Added] changelog to README\r\n\r\n## [Unreleased]\r\n- Environment variable only works using `Environment` while full uppercase is the best practice for environment variables\r\n- `logger.info(\"\", extra={})` parameters are not shown in seq\r\n",
"bugtrack_url": null,
"license": null,
"summary": "python loghandler for seq",
"version": "1.1.1",
"project_urls": {
"Download": "https://pypi.io/packages/source/s/seqpylogger/seqpylogger-1.1.1.tar.gz",
"Homepage": "https://github.com/wearetriple/seqpylogger"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b8fa79865a8f3f7ee2164b6724756bf44a934ca8024edeaba228460ce962e34",
"md5": "934e335f1195c501380249f802bb2762",
"sha256": "089bdaf91fd9d8d0f1356bad60d27dab1c3fc463998b64979ed140696ac75054"
},
"downloads": -1,
"filename": "seqpylogger-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "934e335f1195c501380249f802bb2762",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 14425,
"upload_time": "2024-08-15T12:39:27",
"upload_time_iso_8601": "2024-08-15T12:39:27.291081Z",
"url": "https://files.pythonhosted.org/packages/0b/8f/a79865a8f3f7ee2164b6724756bf44a934ca8024edeaba228460ce962e34/seqpylogger-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-15 12:39:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wearetriple",
"github_project": "seqpylogger",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "seqpylogger"
}