{"id":41374243,"url":"https://github.com/darklab8/py-typelog","last_synced_at":"2026-01-23T09:58:30.616Z","repository":{"id":219502104,"uuid":"749206527","full_name":"darklab8/py-typelog","owner":"darklab8","description":"Static typed structured logging lib","archived":false,"fork":false,"pushed_at":"2024-03-29T10:56:25.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T10:38:03.091Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darklab8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-27T21:58:00.000Z","updated_at":"2024-11-23T15:48:04.000Z","dependencies_parsed_at":"2024-01-27T23:22:28.770Z","dependency_job_id":null,"html_url":"https://github.com/darklab8/py-typelog","commit_stats":null,"previous_names":["darklab8/loguspy","darklab8/py-typelog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darklab8/py-typelog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darklab8%2Fpy-typelog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darklab8%2Fpy-typelog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darklab8%2Fpy-typelog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darklab8%2Fpy-typelog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darklab8","download_url":"https://codeload.github.com/darklab8/py-typelog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darklab8%2Fpy-typelog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28687413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T09:58:29.867Z","updated_at":"2026-01-23T09:58:30.612Z","avatar_url":"https://github.com/darklab8.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typelog - Static typed structured logging\n\n## Description\n\nThis project araised from the need to log backend applications, aws lambdas and other stuff in modern cloud ecosystem. Logging systems today are able easily parsing JSON format out of the box.\nStatic typing approach brings here consistent way to define key values to final msg, as well as easier following Domain Driven Design, where logs consistently describe what they log. Static typed logging brings easy refactoring to any present logs.\n\n## Features\n\n- Accepts static typed components as optional params\n  - it will not accept `any` options\n  - has shortcut WithFields, to make clone of the logger with default logging fields\n- Easy to turn on/off parameters by environment variables\n  - Ability to define different log levels for different created loggers\n- Easier turning complex objects into structured logging\n  - accepts maps and structs as its params. It will parse them on their own.\n[See folder for up to date examples](./examples)\n\n## Alternative Versions\n\n- [Version in golang](https://github.com/darklab8/go-typelog)\n\n## Python specifics\n\n- In order to function with python extra well, recommendation to turn on\n  - [strict mypy](\u003chttps://careers.wolt.com/en/blog/tech/professional-grade-mypy-configuration\u003e)\n  - or pyright in one of [its mods](\u003chttps://github.com/microsoft/pyright/blob/main/docs/configuration.md\u003e)\n- [Published at pypi](https://pypi.org/project/typelog/)\n\n## How to use\n\ninstall with `pip install typelog`\n\nexamples/types.py\n```py\nfrom dataclasses import dataclass\nfrom typing import NewType\n\nTaskID = NewType(\"TaskID\", int)\n\n\n@dataclass(frozen=True)\nclass Task:\n    smth: str\n    b: int\n```\n\nexamples/logtypes.py\n```py\nfrom typing import Any, Dict\n\nfrom typelog import LogType\n\nfrom . import types\n\n\ndef TaskID(value: types.TaskID) -\u003e LogType:\n    def wrapper(params: Dict[str, Any]) -\u003e None:\n        params[\"task_id\"] = str(value)\n\n    return wrapper\n\n\ndef Task(value: types.Task) -\u003e LogType:\n    def wrapper(params: Dict[str, Any]) -\u003e None:\n        params.update(value.__dict__)\n\n    return wrapper\n```\n\nexamples/test_examples.py\n```py\nimport logging\nimport unittest\n\nimport typelog\nfrom typelog import LogConfig, Loggers, get_logger\nfrom typelog.types import LibName, LogLevel, RootLogLevel\n\nfrom . import logtypes, types\n\nlogger = get_logger(__name__)\n\n\nclass TestExamples(unittest.TestCase):\n    def setUp(self) -\u003e None:\n        Loggers(\n            RootLogLevel(logging.DEBUG),\n            LogConfig(LibName(\"examples\"), LogLevel(logging.DEBUG)),\n            add_time=True,\n        ).configure()\n\n    def test_basic(self) -\u003e None:\n        logger.warn(\"Writing something\", logtypes.TaskID(types.TaskID(123)))\n\n    def test_another_one(self) -\u003e None:\n        task = types.Task(smth=\"abc\", b=4)\n        logger.warn(\"Writing something\", logtypes.Task(task))\n\n    def test_with_fields(self) -\u003e None:\n        logger2 = logger.with_fields(logtypes.Task(types.Task(smth=\"aaa\", b=1)))\n        logger3 = logger.with_fields(\n            typelog.String(\"smth\", \"asd\"), typelog.Int(\"number\", 2)\n        )\n\n        logger.info(\"logger printed\")\n        logger2.info(\"logger2 printed\")\n        logger3.info(\"logger3 printed\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarklab8%2Fpy-typelog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarklab8%2Fpy-typelog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarklab8%2Fpy-typelog/lists"}