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

[easylog][fix]fix path when roll files #518

Merged
merged 2 commits into from
Dec 5, 2023
Merged

Conversation

qicosmos
Copy link
Collaborator

@qicosmos qicosmos commented Dec 5, 2023

Why

Close #495

when log dir is not exist, create the dir;

append path when roll files;

What is changing

Example

TEST_CASE("test roll files and automatic create directories") {
  std::string filename = "a/b/c/test.txt";
  std::filesystem::remove(filename);
  CHECK(!std::filesystem::exists(filename));
  constexpr size_t InstanceId = 888;
  easylog::init_log<InstanceId>(Severity::DEBUG, filename, false, true, 20, 3,
                                true);
  CHECK(std::filesystem::exists(filename));
  MELOG_INFO(InstanceId) << 42 << " " << 4.5 << 'a' << " it is a test";
  MELOG_INFO(InstanceId) << 42 << " " << 4.5 << 'a' << " it is a test";
  MELOG_INFO(InstanceId) << 42 << " " << 4.5 << 'a' << " it is a test";

  CHECK(std::filesystem::exists(filename));
  CHECK(std::filesystem::exists("a/b/c/test.1.txt"));
  CHECK(std::filesystem::exists("a/b/c/test.2.txt"));

  std::error_code ec;
  std::filesystem::remove_all("a", ec);
  std::cout << ec.message() << "\n";
}

@qicosmos qicosmos merged commit 2d637af into alibaba:main Dec 5, 2023
30 checks passed
@qicosmos qicosmos deleted the fix_log_path branch December 5, 2023 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[esaylog] 输出到文件时路径问题
1 participant