RunicVTT Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
Logger::LineToLoggerBuf Class Reference
Inheritance diagram for Logger::LineToLoggerBuf:
Collaboration diagram for Logger::LineToLoggerBuf:

Public Member Functions

 LineToLoggerBuf (std::string channel, std::optional< Level > forced=std::nullopt)
 

Protected Member Functions

int overflow (int ch) override
 
std::streamsize xsputn (const char *s, std::streamsize count) override
 
int sync () override
 

Private Member Functions

void flushLine_ ()
 

Private Attributes

std::string channel_
 
std::string buf_
 
std::optional< LevelforcedLevel_
 

Detailed Description

Definition at line 155 of file Logger.h.

Constructor & Destructor Documentation

◆ LineToLoggerBuf()

Logger::LineToLoggerBuf::LineToLoggerBuf ( std::string channel,
std::optional< Level > forced = std::nullopt )
inlineexplicit

Definition at line 159 of file Logger.h.

159 :
160 channel_(std::move(channel)), forcedLevel_(forced) {}
std::string channel_
Definition Logger.h:212
std::optional< Level > forcedLevel_
Definition Logger.h:214

Member Function Documentation

◆ flushLine_()

void Logger::LineToLoggerBuf::flushLine_ ( )
inlineprivate

Definition at line 201 of file Logger.h.

202 {
203 if (!buf_.empty() && buf_.back() == '\n')
204 buf_.pop_back();
205 if (forcedLevel_)
207 else
209 buf_.clear();
210 }
static Logger & instance()
Definition Logger.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ overflow()

int Logger::LineToLoggerBuf::overflow ( int ch)
inlineoverrideprotected

Definition at line 163 of file Logger.h.

164 {
165 if (ch == traits_type::eof())
166 return sync();
167 char c = static_cast<char>(ch);
168 buf_.push_back(c);
169 if (c == '\n')
170 flushLine_();
171 return ch;
172 }
int sync() override
Definition Logger.h:185
Here is the call graph for this function:

◆ sync()

int Logger::LineToLoggerBuf::sync ( )
inlineoverrideprotected

Definition at line 185 of file Logger.h.

186 {
187 if (!buf_.empty())
188 {
189 if (buf_.back() == '\n')
190 buf_.pop_back();
191 if (forcedLevel_)
193 else
194 Logger::instance().log(channel_, buf_); // auto-detect path
195 buf_.clear();
196 }
197 return 0;
198 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ xsputn()

std::streamsize Logger::LineToLoggerBuf::xsputn ( const char * s,
std::streamsize count )
inlineoverrideprotected

Definition at line 173 of file Logger.h.

174 {
175 std::streamsize w = 0;
176 for (; w < count; ++w)
177 {
178 char c = s[w];
179 buf_.push_back(c);
180 if (c == '\n')
181 flushLine_();
182 }
183 return w;
184 }
Here is the call graph for this function:

Member Data Documentation

◆ buf_

std::string Logger::LineToLoggerBuf::buf_
private

Definition at line 213 of file Logger.h.

◆ channel_

std::string Logger::LineToLoggerBuf::channel_
private

Definition at line 212 of file Logger.h.

◆ forcedLevel_

std::optional<Level> Logger::LineToLoggerBuf::forcedLevel_
private

Definition at line 214 of file Logger.h.


The documentation for this class was generated from the following file: