6#ifndef YARP_OS_LOGSTREAM_H
7#define YARP_OS_LOGSTREAM_H
53 std::ostringstream oss;
74 const double externaltime,
77 stream(
new Stream(type, file, line, func, id, externaltime, pred, comp))
90 if (!stream->pred || stream->pred()) {
91 std::string s = stream->oss.str();
97 if (s.back() ==
' ') {
100 yarp::os::Log(stream->file, stream->line, stream->func,
nullptr, yarp::os::Log::logInternalComponent()).
warning(
101 "' ' was expected. Some `operator<<` does not add an extra space at the end");
104 if (!s.empty() && s.back() ==
'\n') {
105 yarp::os::Log(stream->file, stream->line, stream->func,
nullptr, yarp::os::Log::logInternalComponent()).
warning(
106 "Removing extra \\n (stream-style)");
110 Log::do_log(stream->type,
117 stream->externaltime,
133 stream->oss << (
t ?
"true" :
"false");
134 if (!stream->nospace) {
142 if (!stream->nospace) {
150 if (!stream->nospace) {
158 if (!stream->nospace) {
166 if (!stream->nospace) {
174 if (!stream->nospace) {
182 if (!stream->nospace) {
190 if (!stream->nospace) {
198 if (!stream->nospace) {
206 if (!stream->nospace) {
214 if (!stream->nospace) {
222 if (!stream->nospace) {
230 if (!stream->nospace) {
238 if (!stream->nospace) {
246 stream->oss <<
t.c_str();
247 if (!stream->nospace) {
254 template <
typename T1,
typename T2>
257 bool nospace = stream->nospace;
258 stream->nospace =
true;
262 *
this <<
t.second <<
'}';
263 stream->nospace = nospace;
264 if (!stream->nospace) {
270 template <
typename Container,
typename =
typename Container::value_type>
273 return streamInternal(
cont);
276 template <
typename Arr,
typename std::enable_if_t<std::is_array_v<Arr>,
bool> = true>
279 return streamInternal(
arr);
282 template <
typename...
Args>
285 bool nospace = stream->nospace;
286 stream->nospace =
true;
291 template <
typename C>
294 bool nospace = stream->nospace;
295 stream->nospace =
true;
297 for (
auto it = std::begin(
c);
it != std::end(
c); ++
it) {
298 if (
it != std::begin(
c)) {
304 stream->nospace = nospace;
305 if (!stream->nospace) {
311 template <std::size_t I,
typename... Args>
312 inline LogStream& tupleInternal(
const std::tuple<Args...>&
t,
bool nospace)
314 if constexpr (I == 0) {
317 if constexpr (I <
sizeof...(Args)) {
318 if constexpr (I != 0) {
321 *this << std::get<I>(
t);
322 return tupleInternal<I + 1>(
t, nospace);
325 stream->nospace = nospace;
326 if (!stream->nospace) {
void yarp_print_trace(FILE *out, const char *file, unsigned int line)
Low level function for printing a stack trace, if implemented (ACE or gcc/Linux).
A mini-server for performing network communication in the background.
LogStream & operator<<(const std::pair< T1, T2 > &t)
LogStream & operator<<(signed short t)
LogStream & operator<<(const Arr &arr)
LogStream & operator<<(bool t)
LogStream & operator<<(double t)
LogStream & operator<<(const std::tuple< Args... > &t)
LogStream & operator<<(signed long long t)
LogStream(Log::LogType type, const char *file, unsigned int line, const char *func, const char *id, const double externaltime, const yarp::os::Log::Predicate pred=nullptr, const LogComponent &comp=Log::defaultLogComponent())
LogStream & operator<<(unsigned short t)
LogStream & operator<<(const char *t)
LogStream & operator<<(float t)
LogStream & operator<<(unsigned int t)
LogStream(const LogStream &o)
LogStream & operator<<(char t)
LogStream & operator<<(unsigned long long t)
LogStream & operator<<(const void *t)
LogStream & operator<<(signed long t)
LogStream & operator<<(const std::string &t)
LogStream & operator<<(unsigned long t)
LogStream & operator<<(signed int t)
LogStream & operator<<(const Container &cont)
void warning(const char *msg,...) const
static double nowSystem()
bool isClockInitialized()
Check if YARP clock is initialized.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
bool isSystemClock()
Check if YARP is providing system time.
An interface to the operating system, including Port based communication.