# AsyncLog **Repository Path**: mohistH/async-log ## Basic Information - **Project Name**: AsyncLog - **Description**: 一个基于c++11的异步日志库,支持日志滚动记录,支持初始化时自动删除指定日志文件,日志文件格式:年_月_日__时_分_秒__毫秒.log, 比如 2023_06_05__01_00_00_999.log。支持指定日志文件输出路径 - **Primary Language**: C++ - **License**: BSD-3-Clause-Clear - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-06-04 - **Last Updated**: 2024-11-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 0 源码获取 - [gitee](https://gitee.com/mohistH/async-log) # 1 概述 - 这是一个基于`c++11`的异步日志库 - 目前仅支持windows - 已通过 VS2019 + windows11 测试。 - 支持自动清理距今指定天数的日志 - 支持设定日志文件输出路径 ## 2 待实现 - 支持linux ## 3 一个范例 - 使用范例 ``` std::unique_ptrasync_log = std::make_unique(); /// 设置日志记录目录 oct_tk::LogInit li; li.rolling_size_ = 20; /// 将日志记录在可可秩序程序所在目录下的log文件夹 li.foler_ = getExecutablePath() + std::string("/log"); /// 1. 初始化, 参数,设置日志记录路径等参数。 async_log->init(li); /// 2. 启动日志落地线程 async_log->begin(); /// 要写入的日志 const std::string lon_line{"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ~@#$%^&*()_-+=[]{}.,?\n" }; /// 写入 async_log->append(lon_line.c_str(), len); /// 释放 async_log->shutdown(); ```