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

filesystem error: cannot get file size: No such file or directory [***] #247

Closed
oPiZiL opened this issue Feb 13, 2023 · 4 comments · Fixed by #249
Closed

filesystem error: cannot get file size: No such file or directory [***] #247

oPiZiL opened this issue Feb 13, 2023 · 4 comments · Fixed by #249

Comments

@oPiZiL
Copy link

oPiZiL commented Feb 13, 2023

Change current path by fs::current_path will cause filesystem error: cannot get file size: No such file or directory [***] ERROR.

@odygrd
Copy link
Owner

odygrd commented Feb 13, 2023

hello, can you give me more info so i can fix/investigate ?
What do you mean change current path by fs::current_path ? Which Handler are you using ?

@oPiZiL
Copy link
Author

oPiZiL commented Feb 13, 2023

Changes the current working directory to p, as if by POSIX chdir
https://en.cppreference.com/w/cpp/filesystem/current_path

@oPiZiL
Copy link
Author

oPiZiL commented Feb 13, 2023

#include <optional>
#include <experimental/filesystem>
#include <quill/Quill.h>

namespace fs = std::experimental::filesystem;

int main(int argc, char *argv[])
{
    quill::Config cfg;
    cfg.backend_thread_name = "logger_backend";
    cfg.backend_thread_sleep_duration = std::chrono::nanoseconds{ 10000000 };
    cfg.enable_console_colours = true;
    cfg.backend_thread_max_transit_events = 1000;
    quill::configure(cfg);
    quill::start();

    if (!fs::exists("./log")) {
        fs::create_directory("./log");
    }

    std::cout << fs::current_path() << std::endl;
    auto file_handler =
        quill::rotating_file_handler("log/test.log", "a", 5 * 1024, 20);
    file_handler->set_pattern(
        "%(ascii_time) [%(thread)] %(level_name) %(logger_name) - "
        "%(filename):%(lineno) %(message)",
        "%D %H:%M:%S.%Qus", quill::Timezone::LocalTime);
    auto logger = quill::create_logger("LOGGER", file_handler, std::nullopt,
                                       std::nullopt);
    fs::current_path("log"); // setting path
    std::cout << fs::current_path() << std::endl;
    while (1) {
        LOG_INFO(logger, "Welcome to Quill!");
        std::this_thread::sleep_for(std::chrono::milliseconds(1));
    }
    return 0;
}

@odygrd
Copy link
Owner

odygrd commented Feb 13, 2023

thanks, I see what you mean. This is because the Handler stores the relative path and not the absolute one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants