You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really like your work on the language. But your samples use a lot of cout. I find any use of cin/cout/cerr to be flawed in C++. Just raising this, since you don't cite iostream as a C++ flaw.
iostream use is not atomic, requires endl or \n, requires multiple complex formatting functions, can't be stripped, and gets interleaved since the flush can occur at an time. Plus iostream use spreads to other libraries that then implement operator << >>, instead of simply returning a string operator.
I've seen then logging system adopt iostream code, since they have operator << >> defined, so why not. Then it's a nightmare to try and lock and ensure non-interleaved logs across an app. Leave support in for committee members who wrote/think it is an amazing library, but my code is much smaller leaving out of all of iostream for fprintf/std::format type constructs.
Cleaning it up with format helps a bit, but there's no way to skip all this formatting work when this moves to a log system. Use of raw stdout/stderr, and cout/cerr should really be discouraged. This needs the filtering/formatting of a log system. That can add threadName, file, line, level and report specific data to system specific loggers like Android logcat. These systems need the individual fields, and not data formatted into the message of the log.
std::cout<< "Got index "<< i<< "\n";
std::cerr<< "Got index "<< i<< "\n"; // when does this go out?
std::cerr<< "Got index "<< i<< " and " << obj.toString() << "\n";
cleanup
std::cerr << "Got index {} and {}\n".format(i, obj.toString());
I'd much prefer these kinds of constructs instead.
fprintf( stdout, "Got index %d\n", i );
fprintf( stderr, "Got index %d and string %s\n", obj.toString().c_str() );
// can easily strip, early out on debug level, no need to add "\n"
// varargs don't do any formatting if debug level or group is filtered (or macro stripped)
LOGD( "GroupName", "Got index %d", i );
LOGD( "GroupName", "Got string %s", obj.toString().c_str() );
The text was updated successfully, but these errors were encountered:
Here are two examples of logging systems from my project kram for reference. I need to unify to one set of macros to one set. fmt has object support and the system sprintf is typically non-extensible in that regard.
I really like your work on the language. But your samples use a lot of cout. I find any use of cin/cout/cerr to be flawed in C++. Just raising this, since you don't cite iostream as a C++ flaw.
iostream use is not atomic, requires endl or \n, requires multiple complex formatting functions, can't be stripped, and gets interleaved since the flush can occur at an time. Plus iostream use spreads to other libraries that then implement operator << >>, instead of simply returning a string operator.
I've seen then logging system adopt iostream code, since they have operator << >> defined, so why not. Then it's a nightmare to try and lock and ensure non-interleaved logs across an app. Leave support in for committee members who wrote/think it is an amazing library, but my code is much smaller leaving out of all of iostream for fprintf/std::format type constructs.
Cleaning it up with format helps a bit, but there's no way to skip all this formatting work when this moves to a log system. Use of raw stdout/stderr, and cout/cerr should really be discouraged. This needs the filtering/formatting of a log system. That can add threadName, file, line, level and report specific data to system specific loggers like Android logcat. These systems need the individual fields, and not data formatted into the message of the log.
I'd much prefer these kinds of constructs instead.
The text was updated successfully, but these errors were encountered: