{"id":11626994,"url":"https://github.com/to9/embedded-log","last_synced_at":"2025-10-04T15:32:10.905Z","repository":{"id":164453232,"uuid":"111884591","full_name":"to9/embedded-log","owner":"to9","description":"a small and beautiful embedded log library for mcu.","archived":false,"fork":false,"pushed_at":"2023-11-23T05:58:13.000Z","size":142,"stargazers_count":25,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-24T01:03:22.161Z","etag":null,"topics":["embedded","log"],"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/to9.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":"2017-11-24T06:36:37.000Z","updated_at":"2024-06-08T13:38:32.000Z","dependencies_parsed_at":"2023-11-22T05:31:57.433Z","dependency_job_id":null,"html_url":"https://github.com/to9/embedded-log","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/to9%2Fembedded-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/to9%2Fembedded-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/to9%2Fembedded-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/to9%2Fembedded-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/to9","download_url":"https://codeload.github.com/to9/embedded-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876607,"owners_count":16554771,"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":["embedded","log"],"created_at":"2024-06-24T00:31:28.405Z","updated_at":"2025-10-04T15:32:10.545Z","avatar_url":"https://github.com/to9.png","language":"C","funding_links":[],"categories":["User Interface"],"sub_categories":["Logging"],"readme":"## embedded-log\n[![Travis](https://img.shields.io/badge/release-2.0.0-blue.svg?style=plastic)](https://github.com/to9/embedded-log/releases)\n[![Travis](https://img.shields.io/badge/build-passing-brightgreen.svg?style=plastic)](https://github.com/to9/embedded-log/releases)\n[![Crates.io](https://img.shields.io/packagist/l/doctrine/orm.svg?style=plastic)](https://github.com/to9/embedded-log/blob/master/LICENSE)\n\n```\n                 _              _     _          _   _             \n                | |            | |   | |        | | | |            \n   ___ _ __ ___ | |__   ___  __| | __| | ___  __| | | | ___   __ _ \n  / _ \\ '_ ` _ \\| '_ \\ / _ \\/ _` |/ _` |/ _ \\/ _` | | |/ _ \\ / _` |\n |  __/ | | | | | |_) |  __/ (_| | (_| |  __/ (_| | | | (_) | (_| |\n  \\___|_| |_| |_|_.__/ \\___|\\__,_|\\__,_|\\___|\\__,_| |_|\\___/ \\__, |\n                                                ______        __/ |\n                                               |______|      |___/ \n```\n## Description\n\n**`embedded-log`**  is a small and beautiful embedded log library. With color output, log information can be specified to be output to serial port, screen, FLASH, or output to PC through USB. Written in C language, can be used on devices such as C51 and arm.\n\n## View\n- Log serial output:\n\n\u003cdiv align=left\u003e\u003cimg width=\"593\" height=\"123\" src=\"https://github.com/to9/embedded-log/blob/master/images/log1.png\"/\u003e\u003c/div\u003e\n\n\u003cdiv align=left\u003e\u003cimg width=\"592\" height=\"218\" src=\"https://github.com/to9/embedded-log/blob/master/images/log2.png\"/\u003e\u003c/div\u003e\n\n## How is embedded-log used?\n#### 1: Add three files to your project\n- `log_cfg.h`, `log.h`, `log.c`\n\n#### 2: Init log funtcion\n\nYou need to define an output buffer (such as 512 bytes). use **`log_init`** Initialize init and pass in the callback function, call the function as the final output of the data, which can be output to the serial port, USB, screen, internal flash, and any other place you want to output.\n\n```c\nchar g_log_buff[512];\nlog_init(g_log_buff, sizeof(g_log_buff), MID_LOG_Put);\n```\n\n- Dynamic setting of log level， default verbose\n\n  \u003e LOG_LEVEL_CLOS  \n  \u003e LOG_LEVEL_ASSERT  \n  \u003e LOG_LEVEL_ERROR    \n  \u003e LOG_LEVEL_WARNING    \n  \u003e LOG_LEVEL_INFO  \n  \u003e LOG_LEVEL_DEBUG    \n  \u003e LOG_LEVEL_VERBOSE   \n  \n```c\nlog_set_level(LOG_LEVEL_ERROR);\n```\n\n- Output to the serial port\n```c\nvoid MID_LOG_Put(const char *str) {\n\tHAL_UART_Send((UINT_8 *)str, strlen(str));\n}\n```\n- Output to the usb/screen/flash\n```c\nvoid MID_LOG_Put(const char *str) {\n\tHID_USB_WriteData((UINT_8 *)str, strlen(str));\n}\n\nvoid MID_LOG_Put(const char *str) {\n\tMID_TFT_DisInfo_n((UINT_8 *)str, strlen(str), 0, 0);\n}\n\nvoid MID_LOG_Put(const char *str) {\n\tMID_FlashWrite(0x8000, (UINT_8 *)str, strlen(str));\n}\n```\n#### 3: Used function\n```c\n  LOG_ASS(sensors == 1);\n  LOG_ASS_MSG(sensors == 1, \"assert message: %s, len: %d\", buff, sizeof(buff));\n  LOG_ERR(\"recv data error!\");\n  LOG_WRN(\"The file system is not initialized.\");\n  LOG_INF(\"init file system ok.\");\n  LOG_DBG(\"Msg recv length: %d\", u16DataLen);\n  LOG_VBS(\"verbose message\");\n\n  LOG_ASS_HEX(sensors == 1, \"assert message hex\", buff, 32);\n  LOG_ERR_HEX(\"BT Msg:\", g_BtMsgBufCom, u16DataLen);\n  LOG_WRN_HEX(\"BT Msg:\", g_BtMsgBufCom, u16DataLen);\n  LOG_INF_HEX(\"BT Msg:\", g_BtMsgBufCom, u16DataLen);\n  LOG_DBG_HEX(\"BT Msg:\", g_BtMsgBufCom, u16DataLen);\n  LOG_VBS_HEX(\"BT Msg:\", g_BtMsgBufCom, u16DataLen);\n```\n## Advanced used\n\nModifying configuration files can provide more features such as custom colors, style wrapping, and more.\n\n- log_cfg.h\n```c\n#define LOG_DISABLE\t\t\t// 关闭日志功能\n#define LOG_COLOR_ENABLE\t\t// 是否开启彩色输出, 默认开启\n#define LOG_TAGS_ENABLE\t\t\t// 是否输出日志类型标签, 默认输出\n#define LOG_NEWLINE_ENABLE\t\t// 是否使用换行符\"\\r\\n\"\n#define LOG_NEWLINE \"\\r\\n\"              // 配置输出换行符\n```\n\n- Customize log output colors\n```c\n#define LOG_ASS_COLOR \"\\x1B[95m\"\n#define LOG_ERR_COLOR \"\\x1B[91m\"\n#define LOG_WRN_COLOR \"\\x1B[93m\"\n#define LOG_INF_COLOR \"\\x1B[94m\"\n#define LOG_DBG_COLOR \"\\x1B[92m\"\n#define LOG_ASS_HEX_COLOR \"\\x1B[95m\"\n#define LOG_ERR_HEX_COLOR \"\\x1B[91m\"\n#define LOG_WRN_HEX_COLOR \"\\x1B[93m\"\n#define LOG_INF_HEX_COLOR \"\\x1B[94m\"\n#define LOG_DBG_HEX_COLOR \"\\x1B[92m\"\n```\n\n## PC Tool\n- **SecurtCRT**\n  \n  📢: 不支持彩色日志输出，`LOG_COLOR_ENABLE` 应该被关闭\n- **AccessPort** \n  \n  📢: 不支持彩色日志输出，`LOG_COLOR_ENABLE` 应该被关闭。\n- **MobaXtern**\n  \n  支持彩色日志输出。\n## License\n\nCopyright (c) 2017-present, G.D.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fto9%2Fembedded-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fto9%2Fembedded-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fto9%2Fembedded-log/lists"}