{"id":19016602,"url":"https://github.com/wallymathieu/logadapter","last_synced_at":"2026-04-21T03:31:22.097Z","repository":{"id":144134724,"uuid":"67976887","full_name":"wallymathieu/LogAdapter","owner":"wallymathieu","description":"Adapter for library logging (for current and future logging frameworks) inspired by @ezyglide (intended as a pattern, not intended as something you depend on)","archived":false,"fork":false,"pushed_at":"2018-11-26T17:54:07.000Z","size":68,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-01T23:22:48.761Z","etag":null,"topics":["csharp","logadapter","nuget"],"latest_commit_sha":null,"homepage":"","language":"C#","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/wallymathieu.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}},"created_at":"2016-09-12T04:53:22.000Z","updated_at":"2019-01-12T18:30:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"f27fc9f5-62ad-4d30-8ecb-5fc117ea6021","html_url":"https://github.com/wallymathieu/LogAdapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallymathieu%2FLogAdapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallymathieu%2FLogAdapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallymathieu%2FLogAdapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wallymathieu%2FLogAdapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wallymathieu","download_url":"https://codeload.github.com/wallymathieu/LogAdapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240060255,"owners_count":19741806,"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":["csharp","logadapter","nuget"],"created_at":"2024-11-08T19:43:53.702Z","updated_at":"2025-10-07T20:15:51.882Z","avatar_url":"https://github.com/wallymathieu.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogAdapter [![Build Status](https://travis-ci.org/wallymathieu/LogAdapter.svg?branch=master)](https://travis-ci.org/wallymathieu/LogAdapter) [![Build status](https://ci.appveyor.com/api/projects/status/o6k8vkok337gt4by/branch/master?svg=true)](https://ci.appveyor.com/project/wallymathieu/logadapter/branch/master)\n\nAdapter for library logging (for current and future logging frameworks). LogAdapter is not a logging framework. It is intended to be used instead of a logger in order to let the consumer of a library choose how to log things.\n\n## Note\n\nThis is not a library.\n\n## Goal\n\nAvoid taking on a dependency on a logging library for a library. The intent is that in your application code you can take a dependency on a specific version of a logging framework, and create a LogAdapter implementation for that specific version. A library should not determine what kind of logging you choose for your application.\n\n## Installation C#\n\nCopy the following code to your library:\n\n```c#\n    using LogError = Action\u003cstring, Exception\u003e;\n    using LogDebug = Action\u003cstring\u003e;\n```\n\nThen when consuming the library create your adapter for this method.\n\n## Usage\n\n```c#\nusing LogError = Action\u003cstring, Exception\u003e;\nusing LogDebug = Action\u003cstring\u003e;\n\npublic class MyClass\n{\n    private readonly LogError _logError;\n    private readonly LogDebug _logDebug;\n    public MyClass(LogError logError, LogDebug logDebug)\n    {\n        _logError = logError;\n        _logDebug = logDebug;\n    }\n\n    public SomeValue Get(int id) \n    {\n        _logDebug(\"get\");\n        try\n        {\n            // do stuff ...\n            return new SomeValue{ SomeThing=something };\n        }\n        catch (Exception ex)\n        {\n            _logError(\"fail\", ex);\n            return SomeValue.Failure();\n        }\n    }\n}\n```\n\n## Alternatives\n\nLogAdapter is intended to be a minimal logging abstraction. I.e. the goal is not to be a more complete abstraction like for instance:\n\n - [Logary.Facade](https://github.com/logary/logary#using-logary-in-a-library)\n - [Microsoft.Extensions.Logging](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging?view=aspnetcore-2.0) \n - [LibLog](https://github.com/damianh/LibLog) \n\nThis has some pros and cons. If you use this non-library (we assume that you don't use any of the nuget packages provided), then it's easier to plug in any logging abstraction. The downside is that you don't get more than minimal features in your logging. If you look at the type signature used by LogAdapter, it assumes that you use c#. Logary Facade provides and LibLog provides more complete abstractions at the expense of making it more difficult to plug in random logging framework. Microsoft.Extensions.Logging ties your code to specific logging abstractions and requires you to keep up to date with the major versions of that library.\n\n## Why shouldn't you use this approach?\n\nIn f# you might have [less need](http://blog.ploeh.dk/2017/02/02/dependency-rejection/) to use an object oriented dependency injection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallymathieu%2Flogadapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwallymathieu%2Flogadapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwallymathieu%2Flogadapter/lists"}