This commit is contained in:
Ivan
2022-04-05 11:42:28 +03:00
commit 6dc0eb0fcf
5565 changed files with 1200500 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package rosout
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1.12.14 (2018-08-23)
--------------------
1.12.13 (2018-02-21)
--------------------
1.12.12 (2017-11-16)
--------------------
1.12.11 (2017-11-07)
--------------------
1.12.10 (2017-11-06)
--------------------
1.12.9 (2017-11-06)
-------------------
1.12.8 (2017-11-06)
-------------------
1.12.7 (2017-02-17)
-------------------
1.12.6 (2016-10-26)
-------------------
1.12.5 (2016-09-30)
-------------------
1.12.4 (2016-09-19)
-------------------
1.12.3 (2016-09-17)
-------------------
1.12.2 (2016-06-03)
-------------------
1.12.1 (2016-04-18)
-------------------
* use directory specific compiler flags (`#785 <https://github.com/ros/ros_comm/pull/785>`_)
1.12.0 (2016-03-18)
-------------------
1.11.18 (2016-03-17)
--------------------
1.11.17 (2016-03-11)
--------------------
1.11.16 (2015-11-09)
--------------------
1.11.15 (2015-10-13)
--------------------
1.11.14 (2015-09-19)
--------------------
1.11.13 (2015-04-28)
--------------------
1.11.12 (2015-04-27)
--------------------
1.11.11 (2015-04-16)
--------------------
1.11.10 (2014-12-22)
--------------------
1.11.9 (2014-08-18)
-------------------
1.11.8 (2014-08-04)
-------------------
1.11.7 (2014-07-18)
-------------------
1.11.6 (2014-07-10)
-------------------
1.11.5 (2014-06-24)
-------------------
1.11.4 (2014-06-16)
-------------------
1.11.3 (2014-05-21)
-------------------
1.11.2 (2014-05-08)
-------------------
1.11.1 (2014-05-07)
-------------------
1.11.0 (2014-03-04)
-------------------
1.10.0 (2014-02-11)
-------------------
1.9.54 (2014-01-27)
-------------------
1.9.53 (2014-01-14)
-------------------
1.9.52 (2014-01-08)
-------------------
1.9.51 (2014-01-07)
-------------------
* remove log4cxx dependency from rosout, implementing custom rolling log file
1.9.50 (2013-10-04)
-------------------
1.9.49 (2013-09-16)
-------------------
1.9.48 (2013-08-21)
-------------------
1.9.47 (2013-07-03)
-------------------
1.9.46 (2013-06-18)
-------------------
1.9.45 (2013-06-06)
-------------------
1.9.44 (2013-03-21)
-------------------
1.9.43 (2013-03-13)
-------------------
1.9.42 (2013-03-08)
-------------------
1.9.41 (2013-01-24)
-------------------
1.9.40 (2013-01-13)
-------------------
1.9.39 (2012-12-29)
-------------------
* first public release for Groovy

View File

@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 2.8.3)
project(rosout)
if(NOT WIN32)
set_directory_properties(PROPERTIES COMPILE_OPTIONS "-Wall;-Wextra")
endif()
find_package(catkin REQUIRED COMPONENTS roscpp rosgraph_msgs)
catkin_package()
include_directories(${catkin_INCLUDE_DIRS})
add_executable(rosout rosout.cpp)
target_link_libraries(rosout ${catkin_LIBRARIES})
install(TARGETS rosout
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

View File

@@ -0,0 +1,20 @@
<package>
<name>rosout</name>
<version>1.12.14</version>
<description>
System-wide logging mechanism for messages sent to the /rosout topic.
</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<license>BSD</license>
<url>http://ros.org/wiki/rosout</url>
<author>Josh Faust</author>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rosgraph_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rosgraph_msgs</run_depend>
</package>

View File

@@ -0,0 +1,236 @@
/*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstring>
#include <cstdlib>
#include "ros/ros.h"
#include "ros/file_log.h"
#ifdef WIN32
#ifdef ERROR
// ach, windows.h polluting everything again,
// clashes with autogenerated rosgraph_msgs/Log.h
#undef ERROR
#endif
#endif
#include "rosgraph_msgs/Log.h"
/**
* @mainpage
*
* @htmlinclude manifest.html
*
* @b rosout logs messages sent to the /rosout topic,
* which is a system-wide string logging mechanism.
*/
/**
* the rosout node subscribes to /rosout, logs the messages to file, and re-broadcasts the messages to /rosout_agg
*/
class Rosout
{
public:
std::string log_file_name_;
FILE* handle_;
size_t max_file_size_;
size_t current_file_size_;
size_t max_backup_index_;
size_t current_backup_index_;
ros::NodeHandle node_;
ros::Subscriber rosout_sub_;
ros::Publisher agg_pub_;
Rosout()
{
init();
}
void init()
{
max_file_size_ = 100*1024*1024;
current_file_size_ = 0;
max_backup_index_ = 10;
current_backup_index_ = 0;
log_file_name_ = ros::file_log::getLogDirectory() + "/rosout.log";
handle_ = fopen(log_file_name_.c_str(), "w");
if (handle_ == 0)
{
std::cerr << "Error opening rosout log file '" << log_file_name_.c_str() << "': " << strerror(errno);
}
else
{
std::cout << "logging to " << log_file_name_.c_str() << std::endl;
std::stringstream ss;
ss << "\n\n" << ros::Time::now() << " Node Startup\n";
int written = fprintf(handle_, "%s", ss.str().c_str());
if (written < 0)
{
std::cerr << "Error writting to rosout log file '" << log_file_name_.c_str() << "': " << strerror(ferror(handle_)) << std::endl;
}
else if (written > 0)
{
current_file_size_ += written;
if (fflush(handle_))
{
std::cerr << "Error flushing rosout log file '" << log_file_name_.c_str() << "': " << strerror(ferror(handle_));
}
}
}
agg_pub_ = node_.advertise<rosgraph_msgs::Log>("/rosout_agg", 0);
std::cout << "re-publishing aggregated messages to /rosout_agg" << std::endl;
rosout_sub_ = node_.subscribe("/rosout", 0, &Rosout::rosoutCallback, this);
std::cout << "subscribed to /rosout" << std::endl;
}
void rosoutCallback(const rosgraph_msgs::Log::ConstPtr& msg)
{
agg_pub_.publish(msg);
std::stringstream ss;
ss << msg->header.stamp << " ";
switch (msg->level)
{
case rosgraph_msgs::Log::FATAL:
ss << "FATAL ";
break;
case rosgraph_msgs::Log::ERROR:
ss << "ERROR ";
break;
case rosgraph_msgs::Log::WARN:
ss << "WARN ";
break;
case rosgraph_msgs::Log::DEBUG:
ss << "DEBUG ";
break;
case rosgraph_msgs::Log::INFO:
ss << "INFO ";
break;
default:
ss << msg->level << " ";
}
ss << "[" << msg->file << ":" << msg->line << "(" << msg->function << ") ";
ss << "[topics: ";
std::vector<std::string>::const_iterator it = msg->topics.begin();
std::vector<std::string>::const_iterator end = msg->topics.end();
for ( ; it != end; ++it )
{
const std::string& topic = *it;
if ( it != msg->topics.begin() )
{
ss << ", ";
}
ss << topic;
}
ss << "] ";
ss << msg->msg;
ss << "\n";
int written = fprintf(handle_, "%s", ss.str().c_str());
if (written < 0)
{
std::cerr << "Error writting to rosout log file '" << log_file_name_.c_str() << "': " << strerror(ferror(handle_)) << std::endl;
}
else if (written > 0)
{
current_file_size_ += written;
if (fflush(handle_))
{
std::cerr << "Error flushing rosout log file '" << log_file_name_.c_str() << "': " << strerror(ferror(handle_));
}
// check for rolling
if (current_file_size_ > max_file_size_)
{
if (fclose(handle_))
{
std::cerr << "Error closing rosout log file '" << log_file_name_.c_str() << "': " << strerror(ferror(handle_)) << std::endl;
}
current_backup_index_++;
if (current_backup_index_ <= max_backup_index_)
{
std::stringstream backup_file_name;
backup_file_name << log_file_name_ << "." << current_backup_index_;
int rc = rename(log_file_name_.c_str(), backup_file_name.str().c_str());
if (rc != 0)
{
rc = remove(backup_file_name.str().c_str());
if (rc == 0)
{
rc = rename(log_file_name_.c_str(), backup_file_name.str().c_str());
if (rc)
{
std::cerr << "Error rotating rosout log file '" << log_file_name_.c_str() << "' to '" << backup_file_name.str().c_str() << "': " << strerror(errno);
}
}
}
if (rc)
{
std::cerr << "Error rotating rosout log file '" << log_file_name_.c_str() << "'' to '" << backup_file_name.str().c_str() << "'" << std::endl;
}
else
{
std::cout << "rosout log file " << log_file_name_.c_str() << " reached max size, back up data to " << backup_file_name.str().c_str() << std::endl;
}
if (current_backup_index_ == max_backup_index_)
{
current_backup_index_ = 0;
}
}
handle_ = fopen(log_file_name_.c_str(), "w");
if (handle_ == 0)
{
std::cerr << "Error opening rosout log file '" << log_file_name_.c_str() << "': " << strerror(errno);
}
current_file_size_ = 0;
}
}
}
};
int main(int argc, char **argv)
{
ros::init(argc, argv, "rosout", ros::init_options::NoRosout);
ros::NodeHandle n;
Rosout r;
ros::spin();
return 0;
}