Ejemplo n.º 1
0
    def test_logger_wo_params(self, mocked_rospy, logm, rosm):
        name = 'foo'
        message = 'test message'
        log_message = '[{name}:{caller}] {message}'.format(
            name=name,
            caller=self.__class__.__name__ + '.' + sys._getframe().f_code.co_name,
            message=message,
        )

        logger = get_logger(name)
        self.assertEqual(logger.name, name)

        getattr(logger, logm)(message)
        self.assertFalse(mocked_rospy.called)
        self.assertTrue(getattr(mocked_rospy, rosm).called)
        getattr(mocked_rospy, rosm).assert_called_once_with(log_message)
Ejemplo n.º 2
0
    def test_logger_w_args(self, mocked_rospy, logm, rosm):
        name = 'foo'
        message = 'test message'
        arg0 = 'arg0'
        arg1 = 'arg1'
        kwargs0 = 'kwargs0'
        kwargs1 = 'kwargs1'
        log_message = '[{name}:{caller}] {message}, {arg1}, {kwargs0}, {arg0}, {kwargs1}'.format(
            name=name,
            caller=self.__class__.__name__ + '.' + sys._getframe().f_code.co_name,
            message=message,
            arg0=arg0,
            arg1=arg1,
            kwargs0=kwargs0,
            kwargs1=kwargs1,
        )

        logger = get_logger(name)
        self.assertEqual(logger.name, name)

        getattr(logger, logm)(message + ', {1}, {kwargs0}, {0}, {kwargs1}', arg0, arg1, kwargs1=kwargs1, kwargs0=kwargs0)
        self.assertFalse(mocked_rospy.called)
        self.assertTrue(getattr(mocked_rospy, rosm).called)
        getattr(mocked_rospy, rosm).assert_called_once_with(log_message)
Ejemplo n.º 3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import rospy

from fiware_ros_gopigo.gopigo_impl import Gopigo
from fiware_ros_gopigo.logging import get_logger
logger = get_logger(__name__)

NODE_NAME = 'ros_gopigo'


def main():
    try:
        rospy.init_node(NODE_NAME)
        logger.infof('Start node : {}', NODE_NAME)

        gopigo = Gopigo(NODE_NAME)
        gopigo.start()
    except rospy.ROSInterruptException:
        pass


if __name__ == '__main__':
    main()