Project NSCpp.
More...
#include <LogChannel.h>
|
| LogChannel (const std::string &key, const std::string &logFilePrefix) |
| Constructor of the LogChannel.
|
|
void | run (std::stop_token st) |
| Run method of the Channel, process the given events.
|
|
void | log (const std::string &logEntry) |
| Callback which can be used trough the group (based on this channel's key) by other channels.
|
|
| Channel (const std::string &key) |
| Constructor of the Channel's class.
|
|
void | setKey (const std::string &key) |
| Defined the Channel's key.
|
|
const std::string & | getKey () |
| Return the Channel's key.
|
|
void | setState (ChannelState state) |
| Change the state of the server.
|
|
void | push (ClientData data) |
| Add the given data at the end of the queue.
|
|
ClientData | pull () |
| Pop the first data from the queue and return it.
|
|
bool | available () |
| Return true if data is available inside the dataQueue, false otherwise.
|
|
|
void | getStream (const std::string &name) |
| Used to load/create the log file.
|
|
void | loadTime (std::stringstream &ss) |
| Load in the given streamstring the current time in the right format, and change the log file if needed (the date changed).
|
|
|
std::chrono::system_clock::time_point | today |
| Today's date.
|
|
std::string | prefix |
| Log file's prefix.
|
|
std::ofstream | stream |
| Log file's stream.
|
|
std::shared_mutex | mtx |
| Mutex for the log callback.
|
|
std::string | key |
| This key must be unique on the server on which it is plugged.
|
|
std::queue< ClientData > | dataQueue |
| This queue is used to store (and read) the data send to the Channel by the Server.
|
|
ChannelState | state |
| Control if the channel is active or not.
|
|
Project NSCpp.
- Author
- Thomas K/BIDI
- Version
- 2.0
◆ LogChannel()
LogChannel::LogChannel |
( |
const std::string & | key, |
|
|
const std::string & | logFilePrefix ) |
Constructor of the LogChannel.
- Parameters
-
key | Channel's key. |
logFilePrefix | Prefix given to the log files. (Every log file will have the .log extension) |
◆ getStream()
void LogChannel::getStream |
( |
const std::string & | name | ) |
|
|
protected |
Used to load/create the log file.
If the log file already exist it's load and new logs will be append, otherwise it is created.
The log file have the name logFilePrefix + currentData[Y-M-D] + ".log"
- Parameters
-
◆ loadTime()
void LogChannel::loadTime |
( |
std::stringstream & | ss | ) |
|
|
protected |
Load in the given streamstring the current time in the right format, and change the log file if needed (the date changed).
- Parameters
-
ss | Stringstream in which the current time (up to the seconds) is loaded. |
◆ log()
void LogChannel::log |
( |
const std::string & | logEntry | ) |
|
Callback which can be used trough the group (based on this channel's key) by other channels.
Every Channels can call the LogChannel's group and send a message which will be logged.
- Parameters
-
logEntry | Message you want to be logged. |
◆ run()
void LogChannel::run |
( |
std::stop_token | st | ) |
|
|
virtual |
Run method of the Channel, process the given events.
Implements Channel.
◆ mtx
std::shared_mutex LogChannel::mtx |
|
protected |
Mutex for the log callback.
◆ prefix
std::string LogChannel::prefix |
|
protected |
◆ stream
std::ofstream LogChannel::stream |
|
protected |
◆ today
std::chrono::system_clock::time_point LogChannel::today |
|
protected |
The documentation for this class was generated from the following file: