Skip to content

Commit 41c1a08

Browse files
authored
core, plugins: capitalize log message casing (#2929)
Make all log lines start with a capital letter for consistency. Where a line begins with a bare identifier (syscall, function, message or field name), prepend a descriptive word instead of capitalizing the identifier itself, e.g. "getaddrinfo failed" -> "Call getaddrinfo failed".
1 parent fb522ff commit 41c1a08

24 files changed

Lines changed: 115 additions & 114 deletions

cpp/src/mavsdk/core/cli_arg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ bool CliArg::parse_serial(const std::string_view rest, bool flow_control_enabled
276276
return false;
277277
}
278278
} else {
279-
LogErr("serial port needs to start with / or COM on Windows");
279+
LogErr("Serial port needs to start with / or COM on Windows");
280280
return false;
281281
}
282282

@@ -305,7 +305,7 @@ bool CliArg::parse_raw(const std::string_view rest)
305305
{
306306
// raw:// connection has no parameters
307307
if (!rest.empty()) {
308-
LogErr("raw:// connection should not have parameters");
308+
LogErr("A raw:// connection should not have parameters");
309309
return false;
310310
}
311311

cpp/src/mavsdk/core/hostname_to_ip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ std::optional<std::string> resolve_hostname_to_ip(const std::string& hostname)
3333
int res = getaddrinfo(hostname.c_str(), nullptr, &hints, &result);
3434
if (res != 0) {
3535
#if defined(WINDOWS)
36-
LogErr("getaddrinfo failed: {}", WSAGetLastError());
36+
LogErr("Call getaddrinfo failed: {}", WSAGetLastError());
3737
WSACleanup();
3838
#else
39-
LogErr("getaddrinfo failed: {}", gai_strerror(res));
39+
LogErr("Call getaddrinfo failed: {}", gai_strerror(res));
4040
#endif
4141
return {};
4242
}

cpp/src/mavsdk/core/mavlink_command_sender.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void MavlinkCommandSender::receive_command_ack(const mavlink_message_t& message)
227227

228228
case MAV_RESULT_DENIED:
229229
if (_command_debugging) {
230-
LogDebug("command denied ({}).", work->identification.command);
230+
LogDebug("Command denied ({}).", work->identification.command);
231231
if (work->identification.command == 512) {
232232
LogDebug("(message {})", work->identification.maybe_param1);
233233
}
@@ -239,7 +239,7 @@ void MavlinkCommandSender::receive_command_ack(const mavlink_message_t& message)
239239

240240
case MAV_RESULT_UNSUPPORTED:
241241
if (_command_debugging) {
242-
LogDebug("command unsupported ({}).", work->identification.command);
242+
LogDebug("Command unsupported ({}).", work->identification.command);
243243
}
244244
_system_impl.unregister_timeout_handler(work->timeout_cookie);
245245
temp_result = {Result::Unsupported, NAN};
@@ -248,7 +248,7 @@ void MavlinkCommandSender::receive_command_ack(const mavlink_message_t& message)
248248

249249
case MAV_RESULT_TEMPORARILY_REJECTED:
250250
if (_command_debugging) {
251-
LogDebug("command temporarily rejected ({}).", work->identification.command);
251+
LogDebug("Command temporarily rejected ({}).", work->identification.command);
252252
}
253253
_system_impl.unregister_timeout_handler(work->timeout_cookie);
254254
temp_result = {Result::TemporarilyRejected, NAN};
@@ -257,7 +257,7 @@ void MavlinkCommandSender::receive_command_ack(const mavlink_message_t& message)
257257

258258
case MAV_RESULT_FAILED:
259259
if (_command_debugging) {
260-
LogDebug("command failed ({}).", work->identification.command);
260+
LogDebug("Command failed ({}).", work->identification.command);
261261
}
262262
_system_impl.unregister_timeout_handler(work->timeout_cookie);
263263
temp_result = {Result::Failed, NAN};
@@ -289,7 +289,7 @@ void MavlinkCommandSender::receive_command_ack(const mavlink_message_t& message)
289289

290290
case MAV_RESULT_CANCELLED:
291291
if (_command_debugging) {
292-
LogDebug("command cancelled ({}).", work->identification.command);
292+
LogDebug("Command cancelled ({}).", work->identification.command);
293293
}
294294
_system_impl.unregister_timeout_handler(work->timeout_cookie);
295295
temp_result = {Result::Cancelled, NAN};
@@ -360,7 +360,7 @@ void MavlinkCommandSender::receive_timeout(const CommandIdentification& identifi
360360
}
361361

362362
if (!send_mavlink_message(work->command)) {
363-
LogErr("connection send error in retransmit ({}).", work->identification.command);
363+
LogErr("Connection send error in retransmit ({}).", work->identification.command);
364364
temp_callback = work->callback;
365365
temp_result = {Result::ConnectionError, NAN};
366366
_work_queue.erase(it);
@@ -455,7 +455,7 @@ void MavlinkCommandSender::do_work()
455455

456456
{
457457
if (!send_mavlink_message(work->command)) {
458-
LogErr("connection send error ({})", work->identification.command);
458+
LogErr("Connection send error ({})", work->identification.command);
459459
// In this case we try again after the timeout. Chances are slim it will work next
460460
// time though.
461461
} else {

cpp/src/mavsdk/core/mavlink_component_metadata.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MavlinkComponentMetadata::~MavlinkComponentMetadata()
5555
std::error_code ec;
5656
std::filesystem::remove_all(_tmp_download_path, ec);
5757
if (ec) {
58-
LogErr("failed to remove directory: {}", ec.message());
58+
LogErr("Failed to remove directory: {}", ec.message());
5959
}
6060
}
6161

@@ -439,34 +439,34 @@ void MavlinkComponentMetadata::parse_component_metadata_general(
439439
}
440440

441441
if (!metadata.contains("version") || !metadata["version"].is_number_integer()) {
442-
LogErr("version not found");
442+
LogErr("Version not found");
443443
return;
444444
}
445445

446446
if (metadata["version"].get<int>() != 1) {
447-
LogWarn("version {} not supported", metadata["version"].get<int>());
447+
LogWarn("Version {} not supported", metadata["version"].get<int>());
448448
return;
449449
}
450450

451451
if (!metadata.contains("metadataTypes") || !metadata["metadataTypes"].is_array()) {
452-
LogErr("metadataTypes not found");
452+
LogErr("Field metadataTypes not found");
453453
return;
454454
}
455455

456456
for (const auto& metadata_type : metadata["metadataTypes"]) {
457457
if (!metadata_type.is_object() || !metadata_type.contains("type") ||
458458
!metadata_type["type"].is_number_integer()) {
459-
LogErr("type missing");
459+
LogErr("Type missing");
460460
continue;
461461
}
462462
auto type = static_cast<COMP_METADATA_TYPE>(metadata_type["type"].get<int>());
463463
auto& components = _mavlink_components[compid].components;
464464
if (components.find(type) != components.end()) {
465-
LogErr("component type already added: {}", static_cast<int>(type));
465+
LogErr("Component type already added: {}", static_cast<int>(type));
466466
continue;
467467
}
468468
if (!metadata_type.contains("uri")) {
469-
LogErr("uri missing");
469+
LogErr("URI missing");
470470
continue;
471471
}
472472

@@ -625,7 +625,7 @@ std::optional<std::filesystem::path>& MetadataComponent::current_metadata_path()
625625
case State::Init:
626626
break;
627627
}
628-
LogErr("current_metadata_path() called in invalid state");
628+
LogErr("Function current_metadata_path() called in invalid state");
629629
return _metadata;
630630
}
631631
} // namespace mavsdk

cpp/src/mavsdk/core/mavlink_ftp_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ bool MavlinkFtpClient::list_dir_continue(Work& work, ListDirItem& item, PayloadH
11871187
++item.offset;
11881188

11891189
if (_debugging) {
1190-
LogDebug("list_dir raw entry: '{}'", entry);
1190+
LogDebug("Raw entry from list_dir: '{}'", entry);
11911191
}
11921192

11931193
if (entry.empty()) {

cpp/src/mavsdk/core/mavlink_ftp_server.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ void MavlinkFtpServer::_work_remove_directory(const PayloadHeader& payload)
10451045
return;
10461046
}
10471047
if (ec) {
1048-
LogErr("fs::exists for {} returned error: {}", path.string(), ec.message());
1048+
LogErr("Call fs::exists for {} returned error: {}", path.string(), ec.message());
10491049
response.opcode = Opcode::RSP_NAK;
10501050
response.size = 1;
10511051
response.data[0] = ServerResult::ERR_FAIL;
@@ -1054,7 +1054,7 @@ void MavlinkFtpServer::_work_remove_directory(const PayloadHeader& payload)
10541054
}
10551055

10561056
if (!fs::remove(path, ec)) {
1057-
LogErr("fs::remove returned error: {}", ec.message());
1057+
LogErr("Call fs::remove returned error: {}", ec.message());
10581058
response.opcode = Opcode::RSP_NAK;
10591059
response.size = 1;
10601060
response.data[0] = ServerResult::ERR_FAIL;
@@ -1192,7 +1192,8 @@ void MavlinkFtpServer::_work_rename(const PayloadHeader& payload)
11921192

11931193
fs::rename(old_name, new_name, ec);
11941194
if (ec) {
1195-
LogErr("fs::rename from {} to {} returned error: {}", old_name, new_name, ec.message());
1195+
LogErr(
1196+
"Call fs::rename from {} to {} returned error: {}", old_name, new_name, ec.message());
11961197
response.opcode = Opcode::RSP_NAK;
11971198
response.size = 1;
11981199
response.data[0] = ServerResult::ERR_FAIL;

cpp/src/mavsdk/core/mavlink_mission_transfer_client.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ void MavlinkMissionTransferClient::UploadWorkItem::process_mission_request_int(
417417
if (_next_sequence < request_int.seq) {
418418
// We should not go back to a previous one.
419419
// TODO: figure out if we should error here.
420-
LogWarn("mission_request_int: sequence incorrect");
420+
LogWarn("In mission_request_int: sequence incorrect");
421421
return;
422422

423423
} else if (_next_sequence > request_int.seq) {
424424
// We have already sent that one before.
425425
if (_retries_done >= retries) {
426-
LogWarn("mission_request_int: retries exceeded");
426+
LogWarn("In mission_request_int: retries exceeded");
427427
_timeout_handler.remove(_cookie);
428428
callback_and_reset(Result::Timeout);
429429
return;
@@ -447,7 +447,7 @@ void MavlinkMissionTransferClient::UploadWorkItem::process_mission_request_int(
447447
void MavlinkMissionTransferClient::UploadWorkItem::send_mission_item()
448448
{
449449
if (_next_sequence >= _items.size()) {
450-
LogErr("send_mission_item: sequence out of bounds");
450+
LogErr("In send_mission_item: sequence out of bounds");
451451
return;
452452
}
453453

@@ -561,7 +561,7 @@ void MavlinkMissionTransferClient::UploadWorkItem::process_timeout()
561561
}
562562

563563
if (_retries_done >= retries) {
564-
LogWarn("timeout: retries exceeded");
564+
LogWarn("Timeout: retries exceeded");
565565
callback_and_reset(Result::Timeout);
566566
return;
567567
}

cpp/src/mavsdk/core/mavlink_mission_transfer_server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ void MavlinkMissionTransferServer::SendOutgoingMission::process_mission_request_
501501
if (_next_sequence < request_int.seq) {
502502
// We should not go back to a previous one.
503503
// TODO: figure out if we should error here.
504-
LogWarn("mission_request_int: sequence incorrect");
504+
LogWarn("In mission_request_int: sequence incorrect");
505505
return;
506506

507507
} else if (_next_sequence > request_int.seq) {
508508
// We have already sent that one before.
509509
if (_retries_done >= retries) {
510-
LogWarn("mission_request_int: retries exceeded");
510+
LogWarn("In mission_request_int: retries exceeded");
511511
_timeout_handler.remove(_cookie);
512512
callback_and_reset(Result::Timeout);
513513
return;
@@ -528,7 +528,7 @@ void MavlinkMissionTransferServer::SendOutgoingMission::process_mission_request_
528528
void MavlinkMissionTransferServer::SendOutgoingMission::send_mission_item()
529529
{
530530
if (_next_sequence >= _items.size()) {
531-
LogErr("send_mission_item: sequence out of bounds");
531+
LogErr("In send_mission_item: sequence out of bounds");
532532
return;
533533
}
534534

@@ -641,7 +641,7 @@ void MavlinkMissionTransferServer::SendOutgoingMission::process_timeout()
641641
}
642642

643643
if (_retries_done >= retries) {
644-
LogWarn("timeout: retries exceeded");
644+
LogWarn("Timeout: retries exceeded");
645645
callback_and_reset(Result::Timeout);
646646
return;
647647
}

cpp/src/mavsdk/core/mavlink_parameter_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ MavlinkParameterCache::param_by_index(uint16_t param_index, bool including_exten
109109
{
110110
const auto& params = all_parameters(including_extended);
111111
if (param_index >= params.size()) {
112-
LogErr("param at {} out of bounds ({})", (int)param_index, params.size());
112+
LogErr("Param at {} out of bounds ({})", (int)param_index, params.size());
113113
return {};
114114
}
115115

cpp/src/mavsdk/core/mavlink_parameter_client.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ void MavlinkParameterClient::process_param_value(const mavlink_message_t& messag
820820
item.param_name);
821821

822822
if (!send_set_param_message(item)) {
823-
LogErr("connection send error in retransmit ({}).", item.param_name);
823+
LogErr("Connection send error in retransmit ({}).", item.param_name);
824824
_work_queue.pop_front();
825825
if (!_work_queue.empty()) {
826826
asio::post(_io_context, [this] { do_work(); });
@@ -965,7 +965,7 @@ void MavlinkParameterClient::process_param_ext_value(const mavlink_message_t& me
965965
}
966966

967967
if (_parameter_debugging) {
968-
LogDebug("process param_ext_value: {} {}", safe_param_id, received_value.get_string());
968+
LogDebug("Process param_ext_value: {} {}", safe_param_id, received_value.get_string());
969969
}
970970

971971
if (_work_queue.empty()) {
@@ -1068,7 +1068,7 @@ void MavlinkParameterClient::process_param_ext_ack(const mavlink_message_t& mess
10681068
const auto safe_param_id = extract_safe_param_id(param_ext_ack.param_id);
10691069

10701070
if (_parameter_debugging) {
1071-
LogDebug("process param_ext_ack: {} {}", safe_param_id, (int)param_ext_ack.param_result);
1071+
LogDebug("Process param_ext_ack: {} {}", safe_param_id, (int)param_ext_ack.param_result);
10721072
}
10731073

10741074
if (_work_queue.empty()) {
@@ -1141,7 +1141,7 @@ void MavlinkParameterClient::process_param_error(const mavlink_message_t& messag
11411141
const auto safe_param_id = extract_safe_param_id(param_error.param_id);
11421142

11431143
if (_parameter_debugging) {
1144-
LogDebug("process param_error: {} error code: {}", safe_param_id, (int)param_error.error);
1144+
LogDebug("Process param_error: {} error code: {}", safe_param_id, (int)param_error.error);
11451145
}
11461146

11471147
if (_work_queue.empty()) {
@@ -1241,7 +1241,7 @@ void MavlinkParameterClient::receive_timeout()
12411241
item.param_name);
12421242

12431243
if (!send_set_param_message(item)) {
1244-
LogErr("connection send error in retransmit ({}).", item.param_name);
1244+
LogErr("Connection send error in retransmit ({}).", item.param_name);
12451245
_work_queue.pop_front();
12461246
if (!_work_queue.empty()) {
12471247
asio::post(_io_context, [this] { do_work(); });
@@ -1269,9 +1269,9 @@ void MavlinkParameterClient::receive_timeout()
12691269
[&](WorkItemGet& item) {
12701270
if (work->retries_to_do > 0) {
12711271
// We're not sure the command arrived, let's retransmit.
1272-
LogWarn("sending again, retries to do: {}", work->retries_to_do);
1272+
LogWarn("Sending again, retries to do: {}", work->retries_to_do);
12731273
if (!send_get_param_message(item)) {
1274-
LogErr("connection send error in retransmit ");
1274+
LogErr("Connection send error in retransmit ");
12751275
_work_queue.pop_front();
12761276
if (!_work_queue.empty()) {
12771277
asio::post(_io_context, [this] { do_work(); });
@@ -1286,7 +1286,7 @@ void MavlinkParameterClient::receive_timeout()
12861286
}
12871287
} else {
12881288
// We have tried retransmitting, giving up now.
1289-
LogErr("retrying failed");
1289+
LogErr("Retrying failed");
12901290
_work_queue.pop_front();
12911291
if (!_work_queue.empty()) {
12921292
asio::post(_io_context, [this] { do_work(); });
@@ -1372,7 +1372,7 @@ bool MavlinkParameterClient::request_next_missing(uint16_t count)
13721372

13731373
auto next_missing_indices = _param_cache.next_missing_indices(count, chunk_size);
13741374
if (next_missing_indices.empty()) {
1375-
LogErr("logic error, there should a missing index");
1375+
LogErr("Logic error, there should a missing index");
13761376
return false;
13771377
}
13781378

0 commit comments

Comments
 (0)