Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

特性需求:多个日志记录器 & 记录附加模式 #3

Open
2 tasks done
yanminhui opened this issue Jun 7, 2018 · 3 comments
Open
2 tasks done

特性需求:多个日志记录器 & 记录附加模式 #3

yanminhui opened this issue Jun 7, 2018 · 3 comments
Labels
enhancement New feature or request fixing

Comments

@yanminhui
Copy link
Owner

yanminhui commented Jun 7, 2018

  1. 多个日志记录器

每个日志记录器能够加载多个日志槽,每个日志槽可以附加到多个日志记录器,相互独立。

e.g.

dlout(name, level) << message << std::endl;
  1. 记录附加模式
  • 多线程情况下,缓存行记录,直到换行再刷新;
  • 单线程情况下,直接刷新应用。(包括多线程下,日志只在一个线程中生效,有时界面要看到动态效果,如linux启动画面。)
  • 格式化或布局可成为日志槽成员。

e.g.

dlout(name, level) << "loading......";
dlout(name, level) << "ok" << std::endl;
// output: loading...... ok
@yanminhui yanminhui added the enhancement New feature or request label Jun 7, 2018
@yanminhui
Copy link
Owner Author

yanminhui commented Jun 9, 2018

  • 多个日志记录器

commit efe7babcb0f389ea71c7ef3b3446a62b0b6ebc6e

每个日志记录器能够加载多个日志槽,每个日志槽可以附加到多个日志记录器,相互独立。

e.g.

using namespace tinylog;

auto console = registry::instance().create_logger("console");

auto sk = console->create_sink<sink::console_sink>();
sk->set_level(debug);
sk->enable_color(false);

// 可以传递日志记录器 实例 或 名称
// \note dlout --> domain log out
dlprintf(console, info, "c style\n");
dlout("console",  info) << "cpp style" << std::endl;

特定情况:默认日志记录器(兼容以前)

e.g.

using namespace tinylog;

auto inst = registry::instance().create_logger();

auto sk = inst->create_sink<sink::console_sink>();
sk->set_level(debug);
sk->enable_color(false);

// [可选] 不再需要传递日志记录器
lprintf(info, "c style\n");
lout(info) << "cpp style" << std::endl;

@yanminhui
Copy link
Owner Author

yanminhui commented Jun 10, 2018

  • 记录附加模式

commit 97b36a0e4e95e696345b00db025190bd6c335caf
version 1.2.0

受限条件:

  • 使用 endpage_layout 时,确保没有资源竟争!!!
  • 使用 \f 代替换行!!!

e.g.

using namespace tinylog;

auto inst = registry::instance().create_logger();
inst->create_sink<sink::basic_console_sink<char, endpage_layout>>();

lout(info) << "loading...... ";
lout(info) << "ok\f";
// output: 2018-06-10 22:22:30.123456 [INFO] #1 loading...... ok

@yanminhui yanminhui added the ok label Jun 10, 2018
@yanminhui
Copy link
Owner Author

TODO: 记录附加模式 endpage_layout 需要区分是否立即刷新到槽

可以通过模式参数 froce_flush 决定?

@yanminhui yanminhui added fixing and removed ok labels Jun 11, 2018
yanminhui added a commit that referenced this issue Jun 11, 2018
- localtime_s
- std::make_shared<basic_registry>()
yanminhui added a commit that referenced this issue Mar 1, 2019
- localtime_s
- std::make_shared<basic_registry>()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixing
Projects
None yet
Development

No branches or pull requests

1 participant