{"id":20635804,"url":"https://github.com/orsinium-labs/gcp-log","last_synced_at":"2025-07-26T12:07:13.062Z","repository":{"id":166371827,"uuid":"641854038","full_name":"orsinium-labs/gcp-log","owner":"orsinium-labs","description":"Python library to format logs as GCP-compatible JSON.","archived":false,"fork":false,"pushed_at":"2023-08-31T11:18:09.000Z","size":12,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T21:33:56.233Z","etag":null,"topics":["gcp","google-cloud","google-logging","json","logger","logging","orjson","python","structlog","structured-logging"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"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/orsinium-labs.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-17T09:54:13.000Z","updated_at":"2024-12-19T10:54:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"8dae68b8-efd0-4b61-9063-11b937d8a903","html_url":"https://github.com/orsinium-labs/gcp-log","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/orsinium-labs/gcp-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fgcp-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fgcp-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fgcp-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fgcp-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orsinium-labs","download_url":"https://codeload.github.com/orsinium-labs/gcp-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orsinium-labs%2Fgcp-log/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265910223,"owners_count":23847520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["gcp","google-cloud","google-logging","json","logger","logging","orjson","python","structlog","structured-logging"],"created_at":"2024-11-16T15:07:34.228Z","updated_at":"2025-07-26T12:07:13.055Z","avatar_url":"https://github.com/orsinium-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gcp-log\n\nPython library to format logs as [GCP](https://cloud.google.com/)-compatible JSON.\n\nFeatures:\n\n+ Works with standard [logging](https://docs.python.org/3/library/logging.html).\n+ Supports [extra](https://docs.python.org/3/library/logging.html#logging.Logger.debug) for structured logging.\n+ 100% compatible with [the official spec](https://cloud.google.com/logging/docs/structured-logging#special-payload-fields).\n+ Non-invasive, doesn't start any threads or processes, doesn't make network or system calls.\n+ Zero configuration.\n+ Fast.\n+ Pure Python.\n+ Type-safe.\n+ Zero dependency.\n+ Optional integration with [orjson](https://pypi.org/project/orjson/) for better performance.\n\n## Installation\n\n```shell\npython3 -m pip install gcp-log\n```\n\n**Optional:** If you also install [orjson](https://pypi.org/project/orjson/), gcp-log will automatically use it instead of stdlib [json](https://docs.python.org/3/library/json.html) for faster serialization:\n\n```shell\npython3 -m pip install orjson\n```\n\n## Usage\n\nTo use it, simply set `gcp_log.Formatter` as the [formatter](https://docs.python.org/3/library/logging.html#formatter-objects) for the logger:\n\n```python\nimport logging\nimport gcp_log\n\nlogger = logging.getLogger()\nhandler = logging.StreamHandler()\nformatter = gcp_log.Formatter()\nhandler.setFormatter(formatter)\nlogger.addHandler(handler)\n```\n\nAnd then you can use the logger:\n\n```python\nlogger.info('aragorn', extra=dict(father='arathorn'))\n```\n\nThe output:\n\n```json\n{\"message\":\"aragorn\",\"severity\":\"INFO\",\"timestamp\":\"2022-03-17T10:09:58.393124+00:00Z\",\"logging.googleapis.com/sourceLocation\":{\"file\":\"/full/path/to/example.py.py\",\"line\":24,\"function\":\"test_gcp_formatter\"},\"father\":\"arathorn\"}\n```\n\nA human-readable version:\n\n```json\n{\n    \"message\": \"aragorn\",\n    \"severity\": \"INFO\",\n    \"timestamp\": \"2022-03-17T10:09:58.393124+00:00Z\",\n    \"logging.googleapis.com/sourceLocation\": {\n        \"file\": \"/full/path/to/example.py.py\",\n        \"line\": 24,\n        \"function\": \"test_gcp_formatter\",\n    },\n    \"father\": \"arathorn\",\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fgcp-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forsinium-labs%2Fgcp-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forsinium-labs%2Fgcp-log/lists"}