Open jbakosi opened 2 years ago
Answering my own question, with
void longlog( std::string& s, int width = 70 ) {
auto logline = []( char*& e, char* b ){
while (*e == ' ') ++e;
char tmp = *e;
*e = 0;
NLOG(INFO) << b;
*e = tmp;
};
char* b = &s[0];
char* e = b;
while (*(++e) != 0) {
if (*e == '\n' || (e-b > width && *e == ' ')) {
logline( e, b );
b = e;
}
}
if (e > b) logline( e, b );
}
I can do
longlog( longone );
Now if I could call that consistent with other log comands, e.g.,
LOG(INFO) << longone;
that would be great.
@jbakosi May i work on this issue ? I'm new to open source and I'd like to contribute
Is there an automatic way of processing long strings (containing EOL
'\n'
) to appear correctly-prefixed with the FORMAT prefix in the log?That is, when logging
instead of
I would like