Several approaches to a logging class
Singletons

There are several ways to make something a singleton. You are doing it by removing the public constructor, and forcing users to get an instance through a static member function. That works, but there are alternatives. You can create a regular class, and provide a global instance of that class. Just like so:

class Log {
    ...
};

Log logInstance;


You then just refer to logInstance instead of SingletonLog::instance().

Proper naming

Your class has a function log(), however that function does not log anything. Instead, it just returns a std::ostream reference. A more appropriate name for the function would then be get_stream().

If you intend to always use it as SingletonLog::instance().log() &lt;&lt; "some string", then it might be better to just add an operator &lt;&lt;() overload to your logging class. This has several advantages:


It's less typing: SingletonLog::instance() &lt;&lt; "some string", or when using the alternative way of making a singleton: logInstance &lt;&lt; "some string".
You can actually read the contents of the string in your class, and check whether it ends with a newline or not.


Flushing

Whether or not to flush depends on what you want to log. If you log a lot of information, flushing adds considerable overhead. However, if you want to be sure that any errors that are logged are not lost when your program terminates abnormally, then it might be prudent to flush the output stream after every write to the log.

Other suggestions

Do you really want to use the &lt;&lt; operator? If you rather like to use the printf() style, then consider making use of fmtlib, which provides a type-safe way to format strings the printf() or Python .format() way. Your logging class could look like:

#include &lt;fmt/format.h&gt;

class Log {
    template &lt;typename... Args&gt;
    void log(const std::string &amp;format, const Args &amp;... args) {
        std::cout &lt;&lt; fmt::format(format, args...);
    }
};

Log logInstance;


And use it like:

logInstance.log("First line: {}\nSecond line: {}\n", "first entry", "second entry");