# Why rospy.loginfo instead of print

**URL:** <https://get-help.theconstruct.ai/t/why-rospy-loginfo-instead-of-print/5980>\
**Category:** ROS Basics In 5 Days (Python)\
**Created:** [November 1, 2020, 9:08am UTC](https://get-help.theconstruct.ai/t/why-rospy-loginfo-instead-of-print/5980 "2020-11-01T09:08:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdulbasitisdost](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/abdulbasitisdost/32/9348_2.png) [@abdulbasitisdost](https://get-help.theconstruct.ai/u/abdulbasitisdost)\
**Post date:** [November 1, 2020, 9:08am UTC](https://get-help.theconstruct.ai/t/why-rospy-loginfo-instead-of-print/5980/1 "2020-11-01T09:08:34Z")

</div>

In the following code **rospy.loginfo** is used instead of **print()**

```
#! /usr/bin/env python

import rospy
from std_srvs.srv import Empty, EmptyResponse # you import the service message python classes generated from Empty.srv.
from geometry_msgs.msg import Twist

def my_callback(request):
    rospy.loginfo("The Service move_bb8_in_circle has been called")
    move_circle.linear.x = 0.2
    move_circle.angular.z = 0.2
    my_pub.publish(move_circle)
    rospy.loginfo("Finished service move_bb8_in_circle")
    return EmptyResponse() # the service Response class, in this case EmptyResponse

rospy.init_node('service_move_bb8_in_circle_server') 
my_service = rospy.Service('/move_bb8_in_circle', Empty , my_callback) # create the Service called move_bb8_in_circle with the defined callback
my_pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
move_circle = Twist()
rospy.loginfo("Service /move_bb8_in_circle Ready")
rospy.spin() # mantain the service open.

```

I tried looking up in google to understand difference between **print()** and **rospy.loginfo** , but I couldn’t get it.  
Would you please tell me:

1. What’s the difference between **rospy.loginfo** and **print()**?
2. Why are we using **rospy.loginfo** here, in the code above?

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [November 2, 2020, 11:24am UTC](https://get-help.theconstruct.ai/t/why-rospy-loginfo-instead-of-print/5980/2 "2020-11-02T11:24:26Z")

</div>

Simply, `rospy.loginfo()` is an enhanced `print` that produces a more detailed output, useful for debugging. You will learn more in the Debugging unit. In the meantime, you can try using them side by side to see the very clear difference!

---

<div class="post-metadata">

**Author:** ![abdulbasitisdost](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/abdulbasitisdost/32/9348_2.png) [@abdulbasitisdost](https://get-help.theconstruct.ai/u/abdulbasitisdost)\
**Post date:** [November 2, 2020, 11:40am UTC](https://get-help.theconstruct.ai/t/why-rospy-loginfo-instead-of-print/5980/3 "2020-11-02T11:40:37Z")

</div>

Thank you Mr Bayodesegun for all your responses.
