mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
A few clean ups in log.cpp
This commit is contained in:
parent
27cb54c1db
commit
558d749d54
3 changed files with 45 additions and 43 deletions
18
src/log.h
18
src/log.h
|
@ -26,9 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#if !defined(_WIN32) // POSIX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "threading/mutex_auto_lock.h"
|
||||
#include "util/basic_macros.h"
|
||||
#include "util/stream.h"
|
||||
|
@ -73,7 +70,7 @@ public:
|
|||
void logRaw(LogLevel lev, const std::string &text);
|
||||
|
||||
static LogLevel stringToLevel(const std::string &name);
|
||||
static const std::string getLevelLabel(LogLevel lev);
|
||||
static const char *getLevelLabel(LogLevel lev);
|
||||
|
||||
bool hasOutput(LogLevel level) {
|
||||
return m_has_outputs[level].load(std::memory_order_relaxed);
|
||||
|
@ -91,7 +88,7 @@ private:
|
|||
const std::string &time, const std::string &thread_name,
|
||||
const std::string &payload_text);
|
||||
|
||||
const std::string getThreadName();
|
||||
const std::string &getThreadName();
|
||||
|
||||
std::vector<ILogOutput *> m_outputs[LL_MAX];
|
||||
std::atomic<bool> m_has_outputs[LL_MAX];
|
||||
|
@ -120,16 +117,7 @@ public:
|
|||
|
||||
class StreamLogOutput : public ICombinedLogOutput {
|
||||
public:
|
||||
StreamLogOutput(std::ostream &stream) :
|
||||
m_stream(stream)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
if (&stream == &std::cout)
|
||||
is_tty = isatty(STDOUT_FILENO);
|
||||
else if (&stream == &std::cerr)
|
||||
is_tty = isatty(STDERR_FILENO);
|
||||
#endif
|
||||
}
|
||||
StreamLogOutput(std::ostream &stream);
|
||||
|
||||
void logRaw(LogLevel lev, const std::string &line);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue