{"id":27878365,"url":"https://github.com/analogy-logviewer/analogy-python-logging","last_synced_at":"2025-05-05T03:10:34.116Z","repository":{"id":100072189,"uuid":"296720595","full_name":"Analogy-LogViewer/Analogy-Python-Logging","owner":"Analogy-LogViewer","description":"Example of how to send real time log messages from python to Analogy Log Server and view them in Analogy Log Viewer","archived":false,"fork":false,"pushed_at":"2021-08-03T06:52:10.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-21T06:03:32.072Z","etag":null,"topics":["logging","python"],"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/Analogy-LogViewer.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}},"created_at":"2020-09-18T20:13:39.000Z","updated_at":"2021-08-03T06:52:13.000Z","dependencies_parsed_at":"2023-05-12T03:00:16.267Z","dependency_job_id":null,"html_url":"https://github.com/Analogy-LogViewer/Analogy-Python-Logging","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"f6b89292e00570dd4443b0866e3178e0e29549f8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Analogy-LogViewer%2FAnalogy-Python-Logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Analogy-LogViewer%2FAnalogy-Python-Logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Analogy-LogViewer%2FAnalogy-Python-Logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Analogy-LogViewer%2FAnalogy-Python-Logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Analogy-LogViewer","download_url":"https://codeload.github.com/Analogy-LogViewer/Analogy-Python-Logging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429964,"owners_count":21746573,"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":["logging","python"],"created_at":"2025-05-05T03:10:33.472Z","updated_at":"2025-05-05T03:10:34.115Z","avatar_url":"https://github.com/Analogy-LogViewer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analogy-Python-Logging\nExample of how to send real time log messages from python to Analogy Log Server and view them in Analogy Log Viewer\n\nbasically, Just use the already generated Analogy_pb2.py and Analogy_pb2_grpc.py grpc code.\n\nHere is example AnalogyClient.py file that sends dummy messages to Analogy Log Server\n\n\n```python\nimport grpc\nimport Analogy_pb2\nimport Analogy_pb2_grpc\n\n\ndef make_message(message):\n    return Analogy_pb2.AnalogyLogMessage(\n        Text=message,\n\tLevel=\"Information\"\n    )\n\n\ndef generate_messages():\n    messages = [\n        make_message(\"First message\"),\n        make_message(\"Second message\"),\n        make_message(\"Third message\"),\n        make_message(\"Fourth message\"),\n        make_message(\"Fifth message\"),\n    ]\n    for msg in messages:\n        print(\"Hello Server Sending you the %s\" % msg.Text)\n        yield msg\n\n\ndef send_message(stub):\n    stub.SubscribeForSendMessages(generate_messages())\n    print(\"Done\")\n\n\ndef run():\n\n    # open a gRPC channel\n    channel = grpc.insecure_channel('localhost:6000')\n\n    # create a stub (client)\n    stub = Analogy_pb2_grpc.AnalogyStub(channel)\n\n    send_message(stub)\n\n\n\nif __name__ == \"__main__\":\n    run()\n\n```\n\nTo install Analogy Log Server Windows service download it from the [AnalogyLog Server release section](https://github.com/Analogy-LogViewer/Analogy.LogViewer.gRPC/releases/tag/V0.3.4) and install it as descripte in the release.\nAfter that, Open Analogy Log Viewer, go to grpc tab and click on real time.\n\n\nthe proto file is:\n```proto\nsyntax = \"proto3\";\nimport \"timestamp.proto\";\n\npackage greet;\n\n\n// The greeting service definition.\nservice Analogy {\n\t// Sends a greeting\n\trpc SubscribeForPublishingMessages (stream AnalogyGRPCLogMessage) returns (AnalogyMessageReply);\n\trpc SubscribeForConsumingMessages (AnalogyConsumerMessage) returns (stream AnalogyGRPCLogMessage);\n}\n\n// The request message containing the user's name.\nmessage AnalogyGRPCLogMessage {\n\tstring Text = 1;\n\tAnalogyGRPCLogLevel Level = 2;\n\tgoogle.protobuf.Timestamp Date = 3;\n\tint32 ProcessId =4;\n\tint32 ThreadId =5;\n\tstring Module =6;\n\tstring Source = 7;\n\tstring MethodName = 8;\n\tstring FileName = 9;\n\tint32 LineNumber = 10;\n\tstring MachineName=11;\n\tstring Category = 12;\n\tstring User =13;\n\tmap\u003cstring,string\u003e AdditionalInformation=14;\n\tstring Id = 15;\n\tAnalogyGRPCLogClass Class=16;\n}\n\n// The response message containing the greetings.\nmessage AnalogyMessageReply {\n\tstring message = 1;\n}\nmessage AnalogyConsumerMessage {\n\tstring message = 1;\n\tbool streamOldMessages=2;\n}\n\nenum AnalogyGRPCLogClass{\n\tGENERAL=0;\n\t/// \u003csummary\u003e\n\t/// Security logs (audit trails)\n\t/// \u003c/summary\u003e\n\tSECURITY=1;\n\t/// \u003csummary\u003e\n\t/// Hazard issues\n\t/// \u003c/summary\u003e\n\tHAZARD=2;\n\t//\n\t// Summary:\n\t//Protected Health Information\n\tPHI=3;\n}\n\nenum AnalogyGRPCLogLevel\n{\n\tUNKNOWN=0;\n\tTRACE=1;\n\tVERBOSE=2;\n\tDEBUG=3;\n\tINFORMATION=4;\n\tWARNING=5;\n\tERROR=6;\n\tCRITICAL=7;\n\tANALOGY=8;\n\tNONE=9;\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalogy-logviewer%2Fanalogy-python-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanalogy-logviewer%2Fanalogy-python-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalogy-logviewer%2Fanalogy-python-logging/lists"}