C++ multithreading logger class I have designed a logger class to log messages to a file. It uses an independent thread to log the messages save to a queue previously using the main thread. I want to receive reviews about it.
#include &lt;iostream&gt;
#include &lt;queue&gt;
#include &lt;mutex&gt;
#include &lt;condition_variable&gt;
#include &lt;fstream&gt;
#include &lt;atomic&gt;
#include &lt;string&gt;
using namespace std::chrono_literals;

class Logger
{
    std::mutex queueMutex;
    std::condition_variable condVar;
    std::queue&lt;std::string&gt; messagesQueue;
    std::thread loggingThread;//background process launcher
    std::atomic_bool exit = false;//safety condition
    void processEntries()//the background process
    {
        // Open log file.
        std::ofstream logFile(&quot;log.txt&quot;);
        if (logFile.fail()) {
            std::cerr &lt;&lt; &quot;Failed to open logfile.&quot; &lt;&lt; std::endl;
            return;
        }

        // Start processing loop. It process only one message for each iteration
        // to gain more performance
        while (!exit) {
            std::unique_lock lock(queueMutex);

            // Wait for a notification and don't wakeup unless the queue isn't empty.
            condVar.wait(lock, [this]{return !messagesQueue.empty();});

            //log to the file
            logFile &lt;&lt; messagesQueue.front() &lt;&lt; std::endl;
            messagesQueue.pop();
        }

        //At the end, if the queue has some messages. here you don't need mutexes
        // because you have reached the destructor i.e you won't enqueue any messages anymore
        while(exit &amp;&amp; !messagesQueue.empty()){

            //log to the file
            logFile &lt;&lt; messagesQueue.front() &lt;&lt; std::endl;
            messagesQueue.pop();
        }

    }

public:
    Logger()
    {
        //the default ctor launches the background process task
        loggingThread = std::thread{ &amp;Logger::processEntries, this };
    }
    Logger(const Logger&amp; src) = delete;
    Logger&amp; operator=(const Logger&amp; rhs) = delete;

    //logs the messages to the queue
    void log(std::string_view entry)
    {
        std::unique_lock lock(queueMutex);
        messagesQueue.push(std::string(entry));
        condVar.notify_all();
    }


    ~Logger()
    {
        exit = true;
        loggingThread.join();
    }

};


int main(){

    Logger lg;
    for(int i = 1;i &lt; 10000;i++){
        lg.log(&quot;This is the message number &quot; + std::to_string(i));
    }

    std::this_thread::sleep_for(10ms);

    for(int i = 10000;i &lt; 20001;i++){
        lg.log(&quot;This is the message number &quot; + std::to_string(i));
    }

}
Pretty good for a beginning, but I would have a lot of feature requests if I were a user.

Allow the user to provide a full file specification so that the file appears where the user expects it.
The logger should get the day and time of day and report that in each message.
The logger should be initialized with the program name so that the all the messages contain the program name, this way if multiple processes are writing to the same file one will know which process made the log entry.

Make it into a library by providing a header file and a C++ source file.