Needs ROS_PYTHON_LOG_CONFIG_FILE variable, set with e.g.
export ROS_PYTHON_LOG_CONFIG_FILE=$(rospack find wild_thumper)/config/python_logging.conf
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
-find_package(catkin REQUIRED sensor_msgs cv_bridge roscpp std_msgs image_transport dynamic_reconfigure message_generation)
+find_package(catkin REQUIRED sensor_msgs cv_bridge roscpp rospy std_msgs image_transport dynamic_reconfigure message_generation)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
-# catkin_python_setup()
+catkin_python_setup()
################################################
## Declare ROS messages, services and actions ##
--- /dev/null
+[loggers]
+keys=root, rosout
+
+[handlers]
+keys=streamHandler
+
+[formatters]
+keys=defaultFormatter
+
+[logger_root]
+level=INFO
+handlers=streamHandler
+
+[logger_rosout]
+level=INFO
+handlers=streamHandler
+propagate=1
+qualname=rosout
+
+[handler_fileHandler]
+class=handlers.RotatingFileHandler
+level=DEBUG
+formatter=defaultFormatter
+# log filename, mode, maxBytes, backupCount
+args=(os.environ['ROS_LOG_FILENAME'],'a', 50000000, 4)
+
+[handler_streamHandler]
+class=wild_thumper.ros_logging.RosStreamHandler
+level=DEBUG
+formatter=defaultFormatter
+# colorize output flag
+args=(True,)
+
+[formatter_defaultFormatter]
+format=[%(name)s][%(levelname)s] %(asctime)s: %(message)s
<build_depend>sensor_msgs</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>roscpp</build_depend>
+ <build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>openni2_camera</build_depend>
<build_depend>message_generation</build_depend>
+ <run_depend>rospy</run_depend>
<run_depend>hector_sensors_description</run_depend>
<run_depend>openni2_launch</run_depend>
<run_depend>depthimage_to_laserscan</run_depend>
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: iso-8859-15 -*-
+
+from distutils.core import setup
+from catkin_pkg.python_setup import generate_distutils_setup
+
+d = generate_distutils_setup(
+ packages=['wild_thumper'],
+ package_dir={'': 'src'}
+)
+
+setup(**d)
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: iso-8859-15 -*-
+#
+# see https://answers.ros.org/question/174892/ros-log-file-change-of-time-stamping-format/
+
+import os
+import time
+import logging
+import sys
+import datetime
+from rosgraph.roslogging import RosStreamHandler as _RosStreamHandler, _logging_to_rospy_names, _defaultFormatter
+
+
+class RosStreamHandler(_RosStreamHandler):
+ def emit(self, record):
+ level, color = _logging_to_rospy_names[record.levelname]
+ record_message = _defaultFormatter.format(record)
+ msg = os.environ.get('ROSCONSOLE_FORMAT', '[${severity}] [${time}]: ${message}')
+ msg = msg.replace('${severity}', level)
+ msg = msg.replace('${message}', str(record_message))
+ msg = msg.replace('${walltime}', '%f' % time.time())
+ msg = msg.replace('${thread}', str(record.thread))
+ msg = msg.replace('${logger}', str(record.name))
+ msg = msg.replace('${file}', str(record.pathname))
+ msg = msg.replace('${line}', str(record.lineno))
+ msg = msg.replace('${function}', str(record.funcName))
+ try:
+ from rospy import get_name
+ node_name = get_name()
+ except ImportError:
+ node_name = '<unknown_node_name>'
+ msg = msg.replace('${node}', node_name)
+ time_str = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+ msg = msg.replace('${time}', time_str)
+ msg += '\n'
+ if record.levelno < logging.WARNING:
+ self._write(sys.stdout, msg, color)
+ else:
+ self._write(sys.stderr, msg, color)