This repository was archived by the owner on Jun 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Glog logging issue with Eigen3 #695
Copy link
Copy link
Closed
Labels
Description
when i use glog with Eigen3 matrix, i found that every value in Eigen3 matrix is pad with '0'.
I run some tests, and find that
glogwithEigen3matrix: NOT fineglogwithEigen3matrix andstd::setfill(' '): finecoutwithEigen3matrix works: fine- reset stream fill char with
LogMessage::stream().fill(' ')works: fine glogwithdoublevalue andstd::setw(4): NOT fineglogwithdoublevalue,std::setfill(' ')andstd::setw(4): fine
and i check the logging.cc, found stream().fill('0') calling here, why fill('0')?.
shoud we change to stream().fill(' ') or let user to customize padding character?
Line 1216 in a6a166d
| stream().fill('0'); |
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