How to print glog(google log) to console in ros1 noetic in python environment?

asked 2022-10-22 21:31:07 -0500

agua35 gravatar image

I'm working on ros1 noetic and want to print some log on console using glog When I try like below using both rospy.loginfo and, only rospy.loginfo shows on console The peculiarity is that it works well before the "rospy.init_node" and I could see glog at logfile ~/.ros/log/test_node_2209124_1666490747378.log

How to print glog on console after init_node??

python code

import os
import sys
import glog as log
import rospy

def main(args=None):
  args = args or sys.argv[1:]

  log.setLevel("INFO")"glog before init_node")
  rospy.loginfo("rospy.loginfo before init_node")

  rospy.init_node('test_node', log_level=rospy.DEBUG, anonymous=True)"glog after init_node")
  rospy.loginfo("rospy.loginfo after init_node")

  rate = rospy.Rate(1) # 1hz
  while not rospy.is_shutdown():

if__name__ == "__main__":

Output console

I1023 11:05:47.377482 2209124] topicmanager initialized
I1023 11:05:47.378640 2209124] glog before init_node
I1023 11:05:47.378696 2209124] rospy.loginfo before init_node
[DEBUG] [1666490747.499155]: init_node, name[/test_node_2209124_1666490747378], pid[2209124]
[DEBUG] [1666490747.499155]: init_node, name[/test_node_2209124_1666490747378], pid[2209124]
[DEBUG] [1666490747.501007]: binding to 0
[DEBUG] [1666490747.502680]: bound to 34383

[DEBUG] [1666490747.506077]: [/test_node_2209124_1666490747378/get_loggers]: new Service instance

[DEBUG] [1666490747.510686]: [/test_node_2209124_1666490747378/set_logger_level]: new Service instance
[INFO] [1666490747.513658]: rospy.loginfo after init_node
edit retag flag offensive close merge delete