Improve logging
This commit is contained in:
parent
7e538d2388
commit
d120439346
|
@ -43,10 +43,10 @@ void AVehicleSpawnerBase::BeginPlay()
|
|||
TryToSpawnRandomVehicle();
|
||||
++NumberOfAttempts;
|
||||
}
|
||||
}
|
||||
|
||||
if (NumberOfVehicles > Vehicles.Num()) {
|
||||
UE_LOG(LogCarla, Error, TEXT("Requested %d vehicles, but we were only able to spawn %d"), NumberOfVehicles, Vehicles.Num());
|
||||
if (NumberOfVehicles > Vehicles.Num()) {
|
||||
UE_LOG(LogCarla, Error, TEXT("Requested %d vehicles, but we were only able to spawn %d"), NumberOfVehicles, Vehicles.Num());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,12 @@ FPathFollowingRequestResult AWalkerAIController::MoveTo(
|
|||
const FAIMoveRequest& MoveRequest,
|
||||
FNavPathSharedPtr* OutPath)
|
||||
{
|
||||
LOG_AI_WALKER(Log, "requested to move");
|
||||
#ifdef CARLA_AI_WALKERS_EXTRA_LOG
|
||||
UE_LOG(LogCarla, Log, TEXT("Walker %s requested move from (%s) to (%s)"),
|
||||
*GetPawn()->GetName(),
|
||||
*GetPawn()->GetActorLocation().ToString(),
|
||||
*MoveRequest.GetGoalLocation().ToString());
|
||||
#endif // CARLA_AI_WALKERS_EXTRA_LOG
|
||||
Status = EWalkerStatus::Moving;
|
||||
return Super::MoveTo(MoveRequest, OutPath);
|
||||
}
|
||||
|
@ -197,7 +202,11 @@ void AWalkerAIController::OnMoveCompleted(
|
|||
const FPathFollowingResult &Result)
|
||||
{
|
||||
Super::OnMoveCompleted(RequestID, Result);
|
||||
LOG_AI_WALKER(Log, "completed move");
|
||||
#ifdef CARLA_AI_WALKERS_EXTRA_LOG
|
||||
UE_LOG(LogCarla, Log, TEXT("Walker %s completed move at (%s)"),
|
||||
*GetPawn()->GetName(),
|
||||
*GetPawn()->GetActorLocation().ToString());
|
||||
#endif // CARLA_AI_WALKERS_EXTRA_LOG
|
||||
Status = EWalkerStatus::MoveCompleted;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,9 @@ void AWalkerSpawnerBase::SetNumberOfWalkers(const int32 Count)
|
|||
const AWalkerSpawnPointBase &AWalkerSpawnerBase::GetRandomSpawnPoint()
|
||||
{
|
||||
check(SpawnPoints.Num() > 0);
|
||||
return *GetRandomEngine()->PickOne(SpawnPoints);
|
||||
const auto *SpawnPoint = GetRandomEngine()->PickOne(SpawnPoints);
|
||||
check(SpawnPoint != nullptr);
|
||||
return *SpawnPoint;
|
||||
}
|
||||
|
||||
bool AWalkerSpawnerBase::TryGetValidDestination(const FVector &Origin, FVector &Destination)
|
||||
|
|
|
@ -11,6 +11,22 @@
|
|||
// Choose here the log level.
|
||||
#define LOG_LEVEL LOG_LEVEL_ERROR
|
||||
|
||||
// The following log functions are available, they are only active if LOG_LEVEL
|
||||
// is greater equal the function's log level.
|
||||
//
|
||||
// * log_debug
|
||||
// * log_info
|
||||
// * log_error
|
||||
// * log_critical
|
||||
//
|
||||
// And macros
|
||||
//
|
||||
// * LOG_DEBUG_ONLY(/* code here */)
|
||||
// * LOG_INFO_ONLY(/* code here */)
|
||||
|
||||
// =============================================================================
|
||||
// -- Implementation of log functions ------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -20,7 +36,7 @@ namespace detail {
|
|||
|
||||
// https://stackoverflow.com/a/27375675
|
||||
template <typename Arg, typename ... Args>
|
||||
void print_args(std::ostream &out, Arg &&arg, Args &&... args) {
|
||||
static void print_args(std::ostream &out, Arg &&arg, Args &&... args) {
|
||||
out << std::forward<Arg>(arg);
|
||||
using expander = int[];
|
||||
(void)expander{0, (void(out << ' ' << std::forward<Args>(args)),0)...};
|
||||
|
@ -85,3 +101,19 @@ namespace detail {
|
|||
#endif
|
||||
|
||||
} // namespace carla
|
||||
|
||||
// =============================================================================
|
||||
// -- Implementation of macros -------------------------------------------------
|
||||
// =============================================================================
|
||||
|
||||
#if LOG_LEVEL <= LOG_LEVEL_DEBUG
|
||||
# define LOG_DEBUG_ONLY(code) code
|
||||
#else
|
||||
# define LOG_DEBUG_ONLY(code)
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL <= LOG_LEVEL_INFO
|
||||
# define LOG_INFO_ONLY(code) code
|
||||
#else
|
||||
# define LOG_INFO_ONLY(code)
|
||||
#endif
|
||||
|
|
|
@ -70,23 +70,18 @@ namespace thread {
|
|||
_restart = false;
|
||||
_queue.canWait(true);
|
||||
while (!_restart && !done) {
|
||||
{
|
||||
using namespace std;
|
||||
clock_t start = clock();
|
||||
using namespace std;
|
||||
LOG_DEBUG_ONLY(clock_t start = clock();)
|
||||
|
||||
auto value = _queue.wait_and_pop();
|
||||
if (value != nullptr) {
|
||||
_job(*value);
|
||||
|
||||
clock_t end = clock();
|
||||
double elapsed_secs = double(end- start) / CLOCKS_PER_SEC;
|
||||
cout<< "Send Thread: " << elapsed_secs << endl;
|
||||
auto value = _queue.wait_and_pop();
|
||||
if (value != nullptr) {
|
||||
_job(*value);
|
||||
|
||||
LOG_DEBUG_ONLY(clock_t end = clock();)
|
||||
LOG_DEBUG_ONLY(double elapsed_secs = double(end - start) / CLOCKS_PER_SEC;)
|
||||
LOG_DEBUG_ONLY(log_debug("Send Thread:", elapsed_secs);)
|
||||
}
|
||||
|
||||
}//Sleep(10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue