21 bool yarp::os::impl::LogForwarder::started{
false};
31 yarp::os::impl::LogForwarder::LogForwarder()
33 char hostname[HOST_NAME_MAX];
38 outputPort.setWriteOnly();
39 std::string logPortName =
"/log/" + std::string(hostname) +
"/" + processInfo.
name.substr(processInfo.
name.find_last_of(
"\\/") + 1) +
"/" + std::to_string(processInfo.
pid);
40 if (!outputPort.open(logPortName)) {
41 printf(
"LogForwarder error while opening port %s\n", logPortName.c_str());
43 outputPort.enableBackgroundWrite(
true);
44 outputPort.addOutput(
"/yarplogger",
"fast_tcp");
54 std::string port =
"[" + outputPort.getName() +
"]";
64 std::ostringstream ost;
68 ost <<
"(level INFO)";
78 fw.outputPort.
close();
A simple collection of objects that can be described and transmitted in a portable way.
void clear()
Empties the bottle of any objects it contains.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
static std::string toString(int x)
static bool isNetworkInitialized()
void interrupt() override
Interrupt any current reads or writes attached to the port.
void close() override
Stop port activity.
bool isWriting() override
Report whether the port is currently writing data.
static double nowSystem()
static void delaySystem(double seconds)
static ProcessInfo getProcessInfo(int pid=0)
gets the operating system process information given by its PID.
void forward(const std::string &message)
static LogForwarder & getInstance()
double now()
Return the current time in seconds, relative to an arbitrary starting point.
bool isSystemClock()
Check if YARP is providing system time.
void gethostname(char *hostname, size_t size)
Portable wrapper for the gethostname() function.
The ProcessInfo struct provides the operating system process information.