{"id":16410511,"url":"https://github.com/ralpha/google_cloud_logging","last_synced_at":"2026-03-09T08:02:38.282Z","repository":{"id":62439658,"uuid":"440227679","full_name":"ralpha/google_cloud_logging","owner":"ralpha","description":"Google Cloud Structured Logging structures.","archived":false,"fork":false,"pushed_at":"2021-12-20T17:53:14.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-27T13:31:21.563Z","etag":null,"topics":["gcp","google","logging","rust","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralpha.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-20T16:00:18.000Z","updated_at":"2025-02-01T07:44:00.000Z","dependencies_parsed_at":"2022-11-01T22:16:02.768Z","dependency_job_id":null,"html_url":"https://github.com/ralpha/google_cloud_logging","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ralpha/google_cloud_logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralpha%2Fgoogle_cloud_logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralpha%2Fgoogle_cloud_logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralpha%2Fgoogle_cloud_logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralpha%2Fgoogle_cloud_logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralpha","download_url":"https://codeload.github.com/ralpha/google_cloud_logging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralpha%2Fgoogle_cloud_logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30287447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"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":["gcp","google","logging","rust","rust-library"],"created_at":"2024-10-11T06:43:09.102Z","updated_at":"2026-03-09T08:02:38.260Z","avatar_url":"https://github.com/ralpha.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Cloud Logging\n[![Crates.io](https://img.shields.io/crates/v/google_cloud_logging)](https://crates.io/crates/google_cloud_logging/)\n[![API Docs](https://img.shields.io/badge/docs.rs-google_cloud_logging-blue)](https://docs.rs/google_cloud_logging/latest/)\n\nThis crate contains structures for\n[Google Cloud Structured logging](https://cloud.google.com/logging/docs/structured-logging).\nThis allows for adding more metadata to log statements that will be interpreted by the\n[Google Cloud \"Logging\"][Cloud_Logging] service and can be viewed in the \"Logs Explorer\".\n\nSome errors can also be formatted so the [\"Error Reporting\"][Error_Reporting] service will\ngroup them.\n\n[Cloud_Logging]: https://cloud.google.com/logging/\n[Error_Reporting]: https://cloud.google.com/error-reporting/.\n\n## Usage\n\nHere you can see a snippet of how you can use it in you logging library.\n```rust\nlet log_entry = GoogleCloudStructLog {\n    severity: Some(match level {\n        Level::Error =\u003e GCLogSeverity::Error,\n        Level::Warn =\u003e GCLogSeverity::Warning,\n        Level::Info =\u003e GCLogSeverity::Info,\n        Level::Debug =\u003e GCLogSeverity::Debug,\n        Level::Trace =\u003e GCLogSeverity::Default,\n    }),\n    report_type: match level {\n        // More info see: https://cloud.google.com/error-reporting/docs/formatting-error-messages#@type\n        Level::Error =\u003e Some(\"type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent\".to_owned()),\n        _ =\u003e None,\n    },\n    message: Some(\n        format!(\n            \"{}{}\", \n            record.args(),\n            example_backtrace(),\n        )\n    ),\n    operation: Some(GCOperation {\n        id: Some(\"My Service\"),\n        producer: Some(\"MyService.Backend\"),\n        ..Default::default()\n    }),\n    source_location: Some(GCSourceLocation {\n        file: record.file_static(),\n        line: record.line().map(|s| s.to_string()),\n        function: record.module_path_static(),\n    }),\n    time: Some(Utc::now()),\n    ..Default::default()\n};\nprintln!(\n    \"{}\",\n    serde_json::to_string(\u0026log_entry).expect(\"Error during logging\")\n);\n```\n\nTo run the example use: `cargo run --example log`\nThis will result in the following output:\n```json\n{\"severity\":\"info\",\"message\":\"Start logging:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\"time\":\"2021-12-20T16:33:41.643966093Z\",\"logging.googleapis.com/operation\":{\"id\":\"My Service\",\"producer\":\"MyService.Backend\"},\"logging.googleapis.com/sourceLocation\":{\"file\":\"examples/log/main.rs\",\"line\":\"11\",\"function\":\"log\"}}\n{\"severity\":\"warning\",\"message\":\"Oh no, things might go wrong soon.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\"time\":\"2021-12-20T16:33:41.644085317Z\",\"logging.googleapis.com/operation\":{\"id\":\"My Service\",\"producer\":\"MyService.Backend\"},\"logging.googleapis.com/sourceLocation\":{\"file\":\"examples/log/main.rs\",\"line\":\"12\",\"function\":\"log\"}}\n{\"severity\":\"error\",\"message\":\"Yeah, this is not good.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\"@type\":\"type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent\",\"time\":\"2021-12-20T16:33:41.644179397Z\",\"logging.googleapis.com/operation\":{\"id\":\"My Service\",\"producer\":\"MyService.Backend\"},\"logging.googleapis.com/sourceLocation\":{\"file\":\"examples/log/main.rs\",\"line\":\"13\",\"function\":\"log\"}}\n{\"severity\":\"default\",\"message\":\"Something went wrong in `my service`.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\"time\":\"2021-12-20T16:33:41.644276526Z\",\"logging.googleapis.com/operation\":{\"id\":\"My Service\",\"producer\":\"MyService.Backend\"},\"logging.googleapis.com/sourceLocation\":{\"file\":\"examples/log/main.rs\",\"line\":\"14\",\"function\":\"log\"}}\n```\nEach line in the output above is 1 log message. Each log message is a json string.\nNote that this is **not** an array of json messages. Each json object is separated by a newline.\n\n\u003cdetails\u003e\n    \u003csummary\u003eView pretty print:\u003c/summary\u003e\n\n```json\n{\n  \"severity\": \"info\",\n  \"message\": \"Start logging:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\n  \"time\": \"2021-12-20T16:38:13.654978059Z\",\n  \"logging.googleapis.com/operation\": {\n    \"id\": \"My Service\",\n    \"producer\": \"MyService.Backend\"\n  },\n  \"logging.googleapis.com/sourceLocation\": {\n    \"file\": \"examples/log/main.rs\",\n    \"line\": \"11\",\n    \"function\": \"log\"\n  }\n}\n{\n  \"severity\": \"warning\",\n  \"message\": \"Oh no, things might go wrong soon.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\n  \"time\": \"2021-12-20T16:38:13.655138074Z\",\n  \"logging.googleapis.com/operation\": {\n    \"id\": \"My Service\",\n    \"producer\": \"MyService.Backend\"\n  },\n  \"logging.googleapis.com/sourceLocation\": {\n    \"file\": \"examples/log/main.rs\",\n    \"line\": \"12\",\n    \"function\": \"log\"\n  }\n}\n{\n  \"severity\": \"error\",\n  \"message\": \"Yeah, this is not good.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\n  \"@type\": \"type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent\",\n  \"time\": \"2021-12-20T16:38:13.655236672Z\",\n  \"logging.googleapis.com/operation\": {\n    \"id\": \"My Service\",\n    \"producer\": \"MyService.Backend\"\n  },\n  \"logging.googleapis.com/sourceLocation\": {\n    \"file\": \"examples/log/main.rs\",\n    \"line\": \"13\",\n    \"function\": \"log\"\n  }\n}\n{\n  \"severity\": \"default\",\n  \"message\": \"Something went wrong in `my service`.:\\n   at services::module_name::he77c0bac773c93b4 line: 42\\n   at services::module_name::h7ad5e699ac5d6658\",\n  \"time\": \"2021-12-20T16:38:13.655335729Z\",\n  \"logging.googleapis.com/operation\": {\n    \"id\": \"My Service\",\n    \"producer\": \"MyService.Backend\"\n  },\n  \"logging.googleapis.com/sourceLocation\": {\n    \"file\": \"examples/log/main.rs\",\n    \"line\": \"14\",\n    \"function\": \"log\"\n  }\n}\n```\n\n\u003c/details\u003e\n\n## Tips\n\nWhen logging your Rust service you might also want to capture panic message and format them\nthe same way. This can be done using a\n[panic hook](https://doc.rust-lang.org/std/panic/fn.set_hook.html).\n\n## License\n\nThe code in this project is licensed under the MIT or Apache 2.0 license.\n\nAll contributions, code and documentation, to this project will be similarly licensed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralpha%2Fgoogle_cloud_logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralpha%2Fgoogle_cloud_logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralpha%2Fgoogle_cloud_logging/lists"}