{"id":21864584,"url":"https://github.com/2004seraph/cyanlogger","last_synced_at":"2025-03-21T20:45:38.866Z","repository":{"id":95765878,"uuid":"525672968","full_name":"2004seraph/CyanLogger","owner":"2004seraph","description":"A C++17 logging library","archived":false,"fork":false,"pushed_at":"2024-03-12T18:27:27.000Z","size":1275,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-28T04:09:55.816Z","etag":null,"topics":["library","logging","toy-project"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2004seraph.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":"2022-08-17T06:49:35.000Z","updated_at":"2024-03-12T18:28:02.000Z","dependencies_parsed_at":"2023-05-22T00:15:19.688Z","dependency_job_id":null,"html_url":"https://github.com/2004seraph/CyanLogger","commit_stats":null,"previous_names":["2004seraph/cyanlogger"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2004seraph%2FCyanLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2004seraph","download_url":"https://codeload.github.com/2004seraph/CyanLogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235721278,"owners_count":19035104,"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":["library","logging","toy-project"],"created_at":"2024-11-28T04:10:25.604Z","updated_at":"2025-01-26T15:26:03.930Z","avatar_url":"https://github.com/2004seraph.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CyanLogger\n \nThis is a C++17 single-header logging library made for my personal use, but you can use it if you want! It helps me to standardise my console messages which results in a much cleaner console output.\n\n## How to use\n\nInclude the header and instantiate a logger class. The main method will be `Logger::Output`, it can take these arguments:\n - (string) An error type to indicate the level of severity of the message\n - (string) A program module path, for example if your renderer fails to extract a texture from the texture atlas, you would output an error with this module path: \"MYENGINE::RENDERER::TEXTURECROP\"\n - Finally, the error message itself\n\n```cpp\n#include \"CyanLogger.hpp\"\n\n#include \u003cany\u003e\n\nint main(int argc, char* argv[]) {\n    cyan::Logger log;\n\n    log.Output(cyan::Logger::INFO, \"main\", \"Hello world\");\n\n    log.Output(\"This program is useless!\");\n\n    try {\n        //will cause an exception\n        int x = std::any_cast\u003cint\u003e(std::any(\"apple\"));\n    } catch (...) {\n        log.Output(cyan::Errors::INFO, \"main::stupidexample\", \"Inevitable error\");\n    }\n\n    return 0;\n}\n```\n\nThis will output:\n\n```shell\n11:29:34 [Info]: {main} - Hello world\n11:29:34 [Info]: {Anonymous} - This program is useless!\n11:29:34 [Info]: {main::stupidexample} - Inevitable error\n```\n\n### Customizing the output format\n\nThe message output format can be changed by supplying a schema string to either the logger constructor or with the `Logger::SetSchema` method:\n\nThe schema placeholders are:\n - %t = Current time (hh::mm::ss), The logging class makes its method public so that you may also get a time string for your own uses: `Logger::GetTimeString()`\n - %y = Error type\n - %m = Module path\n - %o = The message itself\n\nYou can omit placeholders if you want as well.\n\n```cpp\nlog.SetSchema(\"{%t}--%y===%o - End log\");\n```\n\nThis will change the output of the previous program to:\n\n```shell\n{11:37:29}--Info===Hello world - End log\n{11:37:29}--Info===This program is useless! - End log\n{11:37:29}--Info===Inevitable error - End log\n```\n\n### Dumping history to file\n\nAll logger output messages are recorded in an std::list and this can be dumped to a file with the `Logger::SaveToFile` method:\n\n```cpp\nlog.SaveToFile(\"log.txt\");\n\n//You can also give a path\nlog.SaveToFile(\"debug/log.txt\");\n```\n\nYou can clear the message history with `Logger::ClearMessageHistory()`.\nYou can also get the list of strings for yourself with `Logger::GetMessageHistory()`.\n\n### Provided error types class\n\nAs seen in the provious examples, the class provides some const strings of error types for my convienince, while these are probably sufficient for most situations, you can always not include them by defining `cyanLog_NODEFAULTERRORS` before including `CyanLogger.hpp`.\n\n```cpp\n#define cyanLog_NODEFAULTERRORS\n#include \"CyanLogger.hpp\"\n\nint main(int argc, char* argv[]) {\n\tcyan::Logger log;\n\n    //you may use your own system/convention of error types here.\n    log.Output(\"Output\", \"main\", \"Hello world\");\n}\n```\n\n## Building\n\nThis library uses CMake, you can use cmake-gui to build it like any other library, there are no special settings.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2004seraph%2Fcyanlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2004seraph%2Fcyanlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2004seraph%2Fcyanlogger/lists"}