{"id":19378661,"url":"https://github.com/l-super/vvlog","last_synced_at":"2025-06-30T12:32:03.764Z","repository":{"id":112116181,"uuid":"526608376","full_name":"L-Super/vvlog","owner":"L-Super","description":"Wrapping of the spdlog library","archived":false,"fork":false,"pushed_at":"2022-09-22T03:26:15.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T05:33:24.265Z","etag":null,"topics":["cpp","logger","spdlog"],"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/L-Super.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":"2022-08-19T12:58:35.000Z","updated_at":"2023-03-01T09:23:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"36e0cfaf-cf4f-4e85-9228-bebf356d4870","html_url":"https://github.com/L-Super/vvlog","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/L-Super%2Fvvlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Super%2Fvvlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Super%2Fvvlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-Super%2Fvvlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/L-Super","download_url":"https://codeload.github.com/L-Super/vvlog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240511296,"owners_count":19813237,"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":["cpp","logger","spdlog"],"created_at":"2024-11-10T09:06:38.840Z","updated_at":"2025-02-24T16:19:50.998Z","avatar_url":"https://github.com/L-Super.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 日志库\n\n封装自spdlog\n\n头文件为`vvlog.h`\n\n命名空间 `vv`\n\n## 使用说明\n\n关于打印级别，严重程度递增：\n\n- trace：描述事件的日志级别，显示代码的逐步执行，在标准操作期间可以忽略。\n- debug： 当需要更详细的信息时，使用此调试信息。\n- info：应用程序的运行过程中，输出一些提示信息。\n- warn：应用程序内部发生了意外行为，但它仍在继续工作，关键业务功能按预期运行。\n- error：一项或多项功能无法正常工作，导致某些功能无法正常工作。\n- critical：一项或多项关键业务功能不起作用，整个系统无法实现业务功能。\n\n**通常使用`info` - `critical`级别即可。**\n\n### 控制台打印输出\n\n仅打印到控制台\n\n```cpp\nvv::info()\nvv::warn()\nvv::error()\nvv::critical()\nvv::trace()\nvv::debug()\n```\n\n### 控制台文件同时打印输出\n\n同时打印到控制台及文件。出于性能原因，日志信息不会立即刷新到文件中，默认运行结束后刷新，后可根据情况进行调整。\n\n```cpp\nvv::vvInfo();\nvv::vvWarn();\nvv::vvError();\nvv::vvCritical();\nvv::vvDebug();\nvv::vvTrace();\n```\n\n### 调试模式输出\n\n推荐使用`VINFO()`代替`vv::info()`，因为此方法比`vv::info()`形式更好，可以打印时，带有文件名-函数名-行号格式，方便开发调试过程中的快速定位。\n\n```\nVTRACE()\nVDEBUG()\nVINFO()\nVWARN()\nVERROR()\nVCRITICAL()\n```\n\n## 代码示例\n\n```cpp\n#include \"string\"\n#include \"vvlog.h\"\n\nint main()\n{\n   std::string str{\"hello world\"};\n   vv::vvTrace(\"trace\");//not display\n   vv::vvDebug(\"debug\");//not display\n   vv::vvInfo(str);\n   vv::vvWarn(\"{} {} {} {}\",\"this\",\"is\",\"a\",str);\n   vv::vvError(\"{} != {}\",1,2);\n\n   vv::vvSetGlobalLevel(vv::vvLevel::trace);\n   vv::vvTrace(\"display now\");\n   VDEBUG(\"display now too\");\n   VINFO(\"hello info\");\n   VWARN(str);\n   return 0;\n}\n```\n\n输出：\n\n```\n[2022-09-09 15:05:48.340] [vvlog] [info] hello world\n[2022-09-09 15:05:48.341] [vvlog] [warning] this is a hello world\n[2022-09-09 15:05:48.342] [vvlog] [error] 1 != 2\n[2022-09-09 15:05:48.342] [vvlog] [trace] display now\n[2022-09-09 15:05:48.342] [vvlog] [debug] [example.cpp:14] display now too\n[2022-09-09 15:05:48.343] [vvlog] [info] [example.cpp:16] hello info\n[2022-09-09 15:05:48.343] [vvlog] [warning] [example.cpp:17] hello world\n```\n\n更多示例：\n\n```cpp\nvv::info(\"Welcome\");\nvv::error(\"Some error message with arg: {}\", 1);\nvv::warn(\"Easy padding in numbers like {:08d}\", 12);\nvv::critical(\"Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}\", 42);\nvv::info(\"Support for floats {:03.2f}\", 1.23456);\nvv::info(\"Positional args are {1} {0}..\", \"too\", \"supported\");\nvv::info(\"{:\u003c30}\", \"left aligned\");\n```\n\n## Tips\n\n可以在vvlog.h最后加上一段代码，即可支持QString输出（同时`std::cout`也支持了）。\n\n```c++\ntemplate\u003ctypename OStream\u003e\nOStream\u0026 operator\u003c\u003c(OStream\u0026 os, const QString\u0026 to_log)\n{\n\tvv::fmt_lib::format_to(std::ostream_iterator\u003cchar\u003e(os), \"{}\", to_log.toStdString());\n\treturn os;\n}\n```\n\n对于容器类，也可使用以下方式进行输出：\n\n```c++\nstd::vector\u003cint\u003e v{ 1,2,3,4 };\nvv::vvInfo(\"{}\",vv::fmt_lib::join(v, \", \"));\n//[2022-09-22 11:02:22.843] [vvlog] [info] 1, 2, 3, 4\n```\n\n使用了准C++20 的 std::ranges方式\n\n## 注意\n\n默认不会打印trace,debug级别日志，需要设置日志级别。\n\n```cpp\nvv::vlogger::instance().vSetLevel(vv::vvLevel::trace);\n```\n\n同时，vv::info等仅打印到控制台不受影响。若要开启debug显示，使用以下语句开启全局日志级别设置\n\n```cpp\nvv::vvSetGlobalLevel(vv::vvLevel::trace);\n```\n\n\n\n\n\n----\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-super%2Fvvlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl-super%2Fvvlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-super%2Fvvlog/lists"}