We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when i use glog with Eigen3 matrix, i found that every value in Eigen3 matrix is pad with '0'.
glog
Eigen3
I run some tests, and find that
std::setfill(' ')
cout
LogMessage::stream().fill(' ')
double
std::setw(4)
and i check the logging.cc, found stream().fill('0') calling here, why fill('0')?.
logging.cc
stream().fill('0')
fill('0')
shoud we change to stream().fill(' ') or let user to customize padding character?
stream().fill(' ')
https://github.com/google/glog/blob/master/src/logging.cc#L1588
glog/src/logging.cc
Line 1216 in a6a166d
here's the test code and env
glog version: 0.3.5-1
Eigen version: 3.3.4-4
cpp file
#include <iostream> #include <iomanip> #include <Eigen/Core> #include <glog/logging.h> int main(int /*argc*/, char** /*argv*/) { Eigen::Vector3d a = Eigen::Vector3d::Random(); Eigen::Matrix3d m = Eigen::Matrix3d::Random(); LOG(INFO) << a.transpose(); LOG(INFO) << std::setfill(' ') << a.transpose(); std::cout << a.transpose() << std::endl; LOG(INFO) << std::setw(4) << 1.0; LOG(INFO) << std::setfill(' ') << std::setw(4) << 1.0; google::LogMessage l(__FILE__, __LINE__, google::INFO); l.stream().fill(' '); l.stream() << a.transpose(); return 0; }
cmake file
project(test) cmake_minimum_required(VERSION 3.17) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_FLAGS "-O2 -march=native -no-pie") find_package(Eigen3 REQUIRED) add_definitions(-DEIGEN_NO_DEBUG) include_directories(${EIGEN3_INCLUDE_DIR}) add_executable(test1 test1.cpp) target_link_libraries(test1 glog)
output
$ ./test1 WARNING: Logging before InitGoogleLogging() is written to STDERR I0806 17:56:02.290221 583 test1.cpp:9] 00.680375 -0.211234 00.566198 I0806 17:56:02.290475 583 test1.cpp:10] 0.680375 -0.211234 0.566198 0.680375 -0.211234 0.566198 I0806 17:56:02.290553 583 test1.cpp:12] 0001 I0806 17:56:02.290572 583 test1.cpp:13] 1 I0806 17:56:02.290589 583 test1.cpp:14] 0.680375 -0.211234 0.566198
The text was updated successfully, but these errors were encountered:
We should save the previous fill character and restore it afterwards.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
when i use
glog
withEigen3
matrix, i found that every value inEigen3
matrix is pad with '0'.I run some tests, and find that
glog
withEigen3
matrix: NOT fineglog
withEigen3
matrix andstd::setfill(' ')
: finecout
withEigen3
matrix works: fineLogMessage::stream().fill(' ')
works: fineglog
withdouble
value andstd::setw(4)
: NOT fineglog
withdouble
value,std::setfill(' ')
andstd::setw(4)
: fineand i check the
logging.cc
, foundstream().fill('0')
calling here, whyfill('0')
?.shoud we change to
stream().fill(' ')
or let user to customize padding character?https://github.com/google/glog/blob/master/src/logging.cc#L1588
glog/src/logging.cc
Line 1216 in a6a166d
here's the test code and env
glog version: 0.3.5-1
Eigen version: 3.3.4-4
cpp file
cmake file
output
The text was updated successfully, but these errors were encountered: