{"id":13805072,"url":"https://github.com/deavmi/dlog","last_synced_at":"2025-05-13T18:33:12.657Z","repository":{"id":71437305,"uuid":"441127561","full_name":"deavmi/dlog","owner":"deavmi","description":"Simple and modular logging library","archived":false,"fork":false,"pushed_at":"2025-03-21T12:07:36.000Z","size":87,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T13:23:20.917Z","etag":null,"topics":["dlang","library","logging"],"latest_commit_sha":null,"homepage":"https://deavmi.assigned.network/projects/dlog","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deavmi.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":"2021-12-23T09:23:52.000Z","updated_at":"2025-03-21T12:07:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"607f53f3-ead0-4d31-aafb-e0e42e882496","html_url":"https://github.com/deavmi/dlog","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deavmi%2Fdlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deavmi%2Fdlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deavmi%2Fdlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deavmi%2Fdlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deavmi","download_url":"https://codeload.github.com/deavmi/dlog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254003490,"owners_count":21997896,"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":["dlang","library","logging"],"created_at":"2024-08-04T01:00:57.179Z","updated_at":"2025-05-13T18:33:11.968Z","avatar_url":"https://github.com/deavmi.png","language":"D","funding_links":[],"categories":["Command Line"],"sub_categories":["XML"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"branding/logo.png\" width=220\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n\u003ch1 align=\"center\"\u003edlog\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003e\u003ci\u003e\u003cb\u003eSimple and modular logging library\u003c/i\u003e\u003c/b\u003e\u003c/h3\u003e\n\n---\n\n\u003cbr\u003e\n\u003cbr\n\n\n`[2021-Dec-23 11:17:35.3527637]\t(source/dlog/testing/thing.d:12): This is a log message`\n\n---\n    \n[![D](https://github.com/deavmi/dlog/actions/workflows/d.yml/badge.svg)](https://github.com/deavmi/dlog/actions/workflows/d.yml)\n\n## Usage\n\nWe recommend you use [dub](http://code.dlang.org) to add dlog to your project as follows:\n\n```\ndub add dlog\n```\n\n* [View on DUB](https://code.dlang.org/packages/dlog)\n* [View API](https://dlog.dpldocs.info/)\n\n### Components\n\ndlog is formed out of two main components:\n\n1. `Logger`\n\t* The logger contains the needed barebones for facilitating the actual logging of text\n\t* The _base logger_ (i.e. `Logger`) maintains a list of attaches _filters_, _message transformers_ and _handlers_\n2. `Filter`\n\t* Acts as a predicate on the incoming _message_ and determines whether it should be logged or not\n\t* This is used by the `BasicLogger` to implement log levels\n3. `Transform`\n\t* A _message transform_ is attached to a logger and performs manipulation on the message logged\n\t* They may be chained as to perform multiple transformations in a stream-like fashion\n4. `Handler`\n\t* A _handler_ handles the final transformed message, for some this means outputting to standard out, or a file\n\n### Quick start\n\nIf you want to immediately begin logging text using the defaults and don't care about implementing your own transformations then you can \nsimply use the default logger as follows:\n\n```d\nimport dlog;\n\nDefaultLogger logger = new DefaultLogger();\n\nlogger.setLevel(Level.DEBUG);\nlogger.error([\"woah\", \"LEVELS!\"], 69.420);\nlogger.info([\"woah\", \"LEVELS!\"], 69.420);\nlogger.warn([\"woah\", \"LEVELS!\"], 69.420);\nlogger.debug_([\"woah\", \"LEVELS!\"], 69.420);\n\n// Should not be able to see this\nlogger.setLevel(Level.INFO);\nlogger.debug_(\"Can't see me!\");\n```\n\nThis will output the following:\n\n```\n[2024-Apr-09 19:14:38.3077171]  (ERROR): [\"woah\", \"LEVELS!\"] 69.42\n[2024-Apr-09 19:14:38.3077346]  (INFO): [\"woah\", \"LEVELS!\"] 69.42\n[2024-Apr-09 19:14:38.3077559]  (WARN): [\"woah\", \"LEVELS!\"] 69.42\n[2024-Apr-09 19:14:38.3077759]  (DEBUG): [\"woah\", \"LEVELS!\"] 69.42\n```\n\nYou can see the [full API](https://dlog.dpldocs.info/) for more information.\n\n### Custom loggers\n\n#### Implementing your own transform\n\nPerhaps the default transformation, `DefaultTransform`, may not be what you want. Maybe you want the module name included in the logged\nmessages or perhaps don't want the date-and-timestamp included at all. All of this can be up to you if you choose to implement your own\nmessage transform.\n\nYou will need to start off with a class that inherits from the `Transform` class and then which overrides the `transform` method as shown below:\n\n```d\nimport dlog;\n\npublic class CustomTransform : Transform\n{\n\tpublic override Message transform(Message message)\n\t{\n\t\tBasicMessage bmesg = cast(BasicMessage)message;\n\t\t\n\t\t// Only handle BasicMessage(s) - ones which have `setText(string)`\n\t\tif(bmesg is null)\n\t\t{\n\t\t\treturn message;\n\t\t}\n\n\t\tstring transformed;\n\t\t/* Insert transformation code here */\n\t\tbmesg.setText(transformed);\n\n\t\treturn message;\n\t}\n}\n```\n\n## License\n\nLGPL v3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeavmi%2Fdlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeavmi%2Fdlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeavmi%2Fdlog/lists"}