Prefix LOG and CHECK with AOS_

This prepares us for introducing glog more widely and transitioning
things over where they make sense.

Change-Id: Ic6c208882407bc2153fe875ffc736d66f5c8ade5
diff --git a/frc971/wpilib/ADIS16448.cc b/frc971/wpilib/ADIS16448.cc
index 38d194d..4fc2c7b 100644
--- a/frc971/wpilib/ADIS16448.cc
+++ b/frc971/wpilib/ADIS16448.cc
@@ -25,7 +25,7 @@
   rx_clearer_.ClearRxFifo();
   switch (spi_->Transaction(to_send, to_receive, size)) {
     case -1:
-      LOG(INFO, "SPI::Transaction of %zd bytes failed\n", size);
+      AOS_LOG(INFO, "SPI::Transaction of %zd bytes failed\n", size);
       return false;
     case size:
       if (dummy_spi_) {
@@ -34,7 +34,7 @@
       }
       return true;
     default:
-      LOG(FATAL, "SPI::Transaction returned something weird\n");
+      AOS_LOG(FATAL, "SPI::Transaction returned something weird\n");
   }
 }
 
@@ -142,7 +142,7 @@
 
   // NI's SPI driver defaults to SCHED_OTHER.  Find it's PID with ps, and change
   // it to a RT priority of 33.
-  PCHECK(
+  AOS_PCHECK(
       system("ps -ef | grep '\\[spi0\\]' | awk '{print $1}' | xargs chrt -f -p "
              "33") == 0);
 
@@ -180,7 +180,7 @@
       ::std::this_thread::sleep_for(::std::chrono::milliseconds(50));
     }
   }
-  LOG(INFO, "IMU initialized successfully\n");
+  AOS_LOG(INFO, "IMU initialized successfully\n");
 }
 
 void ADIS16448::DoRun() {
@@ -201,7 +201,7 @@
       const frc::InterruptableSensorBase::WaitResult result =
           dio1_->WaitForInterrupt(0.1, !got_an_interrupt);
       if (result == frc::InterruptableSensorBase::kTimeout) {
-        LOG(WARNING, "IMU read timed out\n");
+        AOS_LOG(WARNING, "IMU read timed out\n");
         InitializeUntilSuccessful();
         continue;
       }
@@ -221,7 +221,7 @@
     // scenario.
     if (!dio1_->Get() || dio1_->WaitForInterrupt(0, false) !=
                              frc::InterruptableSensorBase::kTimeout) {
-      LOG(ERROR, "IMU read took too long\n");
+      AOS_LOG(ERROR, "IMU read took too long\n");
       continue;
     }
 
@@ -230,8 +230,9 @@
       uint16_t received_crc =
           to_receive[13 * 2 + 1] | (to_receive[13 * 2] << 8);
       if (received_crc != calculated_crc) {
-        LOG(WARNING, "received CRC %" PRIx16 " but calculated %" PRIx16 "\n",
-            received_crc, calculated_crc);
+        AOS_LOG(WARNING,
+                "received CRC %" PRIx16 " but calculated %" PRIx16 "\n",
+                received_crc, calculated_crc);
         InitializeUntilSuccessful();
         continue;
       }
@@ -274,9 +275,9 @@
           gyro_x_zeroed_offset_ = -average_gyro_x.GetAverage();
           gyro_y_zeroed_offset_ = -average_gyro_y.GetAverage();
           gyro_z_zeroed_offset_ = -average_gyro_z.GetAverage();
-          LOG(INFO, "total gyro zero offset X:%f, Y:%f, Z:%f\n",
-              gyro_x_zeroed_offset_, gyro_y_zeroed_offset_,
-              gyro_z_zeroed_offset_);
+          AOS_LOG(INFO, "total gyro zero offset X:%f, Y:%f, Z:%f\n",
+                  gyro_x_zeroed_offset_, gyro_y_zeroed_offset_,
+                  gyro_z_zeroed_offset_);
           gyros_are_zeroed_ = true;
         }
       }
@@ -306,9 +307,9 @@
     message->temperature =
         ConvertValue(&to_receive[24], kTemperatureLsbDegree) + kTemperatureZero;
 
-    LOG_STRUCT(DEBUG, "sending", *message);
+    AOS_LOG_STRUCT(DEBUG, "sending", *message);
     if (!message.Send()) {
-      LOG(WARNING, "sending queue message failed\n");
+      AOS_LOG(WARNING, "sending queue message failed\n");
     }
 
     spi_idle_callback_();
@@ -355,51 +356,51 @@
 bool ADIS16448::CheckDiagStatValue(uint16_t value) const {
   bool r = true;
   if (value & (1 << 2)) {
-    LOG(WARNING, "IMU gave flash update failure\n");
+    AOS_LOG(WARNING, "IMU gave flash update failure\n");
   }
   if (value & (1 << 3)) {
-    LOG(WARNING, "IMU gave SPI communication failure\n");
+    AOS_LOG(WARNING, "IMU gave SPI communication failure\n");
   }
   if (value & (1 << 4)) {
-    LOG(WARNING, "IMU gave sensor overrange\n");
+    AOS_LOG(WARNING, "IMU gave sensor overrange\n");
   }
   if (value & (1 << 5)) {
-    LOG(WARNING, "IMU gave self-test failure\n");
+    AOS_LOG(WARNING, "IMU gave self-test failure\n");
     r = false;
     if (value & (1 << 10)) {
-      LOG(WARNING, "IMU gave X-axis gyro self-test failure\n");
+      AOS_LOG(WARNING, "IMU gave X-axis gyro self-test failure\n");
     }
     if (value & (1 << 11)) {
-      LOG(WARNING, "IMU gave Y-axis gyro self-test failure\n");
+      AOS_LOG(WARNING, "IMU gave Y-axis gyro self-test failure\n");
     }
     if (value & (1 << 12)) {
-      LOG(WARNING, "IMU gave Z-axis gyro self-test failure\n");
+      AOS_LOG(WARNING, "IMU gave Z-axis gyro self-test failure\n");
     }
     if (value & (1 << 13)) {
-      LOG(WARNING, "IMU gave X-axis accelerometer self-test failure\n");
+      AOS_LOG(WARNING, "IMU gave X-axis accelerometer self-test failure\n");
     }
     if (value & (1 << 14)) {
-      LOG(WARNING, "IMU gave Y-axis accelerometer self-test failure\n");
+      AOS_LOG(WARNING, "IMU gave Y-axis accelerometer self-test failure\n");
     }
     if (value & (1 << 15)) {
-      LOG(WARNING, "IMU gave Z-axis accelerometer self-test failure, %x\n",
-          value);
+      AOS_LOG(WARNING, "IMU gave Z-axis accelerometer self-test failure, %x\n",
+              value);
     }
     if (value & (1 << 0)) {
-      LOG(WARNING, "IMU gave magnetometer functional test failure\n");
+      AOS_LOG(WARNING, "IMU gave magnetometer functional test failure\n");
     }
     if (value & (1 << 1)) {
-      LOG(WARNING, "IMU gave barometer functional test failure\n");
+      AOS_LOG(WARNING, "IMU gave barometer functional test failure\n");
     }
   }
   if (value & (1 << 6)) {
-    LOG(WARNING, "IMU gave flash test checksum failure\n");
+    AOS_LOG(WARNING, "IMU gave flash test checksum failure\n");
   }
   if (value & (1 << 8)) {
-    LOG(WARNING, "IMU says alarm 1 is active\n");
+    AOS_LOG(WARNING, "IMU says alarm 1 is active\n");
   }
   if (value & (1 << 9)) {
-    LOG(WARNING, "IMU says alarm 2 is active\n");
+    AOS_LOG(WARNING, "IMU says alarm 2 is active\n");
   }
   return r;
 }
@@ -409,7 +410,7 @@
   uint16_t product_id;
   if (!ReadRegister(kLotId1Address, &product_id)) return false;
   if (product_id != 0x4040) {
-    LOG(ERROR, "product ID is %" PRIx16 " instead of 0x4040\n", product_id);
+    AOS_LOG(ERROR, "product ID is %" PRIx16 " instead of 0x4040\n", product_id);
     return false;
   }
 
@@ -417,8 +418,8 @@
   if (!ReadRegister(kLotId2Address, &lot_id1)) return false;
   if (!ReadRegister(kSerialNumberAddress, &lot_id2)) return false;
   if (!ReadRegister(0, &serial_number)) return false;
-  LOG(INFO, "have IMU %" PRIx16 "%" PRIx16 ": %" PRIx16 "\n", lot_id1, lot_id2,
-      serial_number);
+  AOS_LOG(INFO, "have IMU %" PRIx16 "%" PRIx16 ": %" PRIx16 "\n", lot_id1,
+          lot_id2, serial_number);
 
   // Divide the sampling by 2^2 = 4 to get 819.2 / 4 = 204.8 Hz.
   if (!WriteRegister(kSmplPrdAddress, (2 << 8) | 1)) return false;
diff --git a/frc971/wpilib/buffered_pcm.cc b/frc971/wpilib/buffered_pcm.cc
index de8c547..3123add 100644
--- a/frc971/wpilib/buffered_pcm.cc
+++ b/frc971/wpilib/buffered_pcm.cc
@@ -16,7 +16,7 @@
     solenoid_handles_[i] =
         HAL_InitializeSolenoidPort(HAL_GetPortWithModule(module_, i), &status);
     if (status != 0) {
-      LOG(FATAL, "Status was %d\n", status);
+      AOS_LOG(FATAL, "Status was %d\n", status);
     }
   }
 }
@@ -38,18 +38,18 @@
   int32_t status = 0;
   int32_t result = HAL_GetAllSolenoids(module_, &status);
   if (status != 0) {
-    LOG(ERROR, "Failed to flush, %d\n", status);
+    AOS_LOG(ERROR, "Failed to flush, %d\n", status);
     return 0;
   }
   return result;
 }
 
 void BufferedPcm::Flush() {
-  LOG(DEBUG, "sending solenoids 0x%" PRIx8 "\n", values_);
+  AOS_LOG(DEBUG, "sending solenoids 0x%" PRIx8 "\n", values_);
   int32_t status = 0;
   HAL_SetAllSolenoids(module_, static_cast<int>(values_), &status);
   if (status != 0) {
-    LOG(ERROR, "Failed to flush, %d\n", status);
+    AOS_LOG(ERROR, "Failed to flush, %d\n", status);
   }
 }
 
diff --git a/frc971/wpilib/dma_edge_counting.cc b/frc971/wpilib/dma_edge_counting.cc
index 9fffebe..1b7bee9 100644
--- a/frc971/wpilib/dma_edge_counting.cc
+++ b/frc971/wpilib/dma_edge_counting.cc
@@ -57,7 +57,7 @@
       case DMA::STATUS_TIMEOUT:
         return;
       case DMA::STATUS_ERROR:
-        LOG(WARNING, "DMA read failed\n");
+        AOS_LOG(WARNING, "DMA read failed\n");
         break;
     }
   }
diff --git a/frc971/wpilib/drivetrain_writer.cc b/frc971/wpilib/drivetrain_writer.cc
index fdbc028..5c6feb8 100644
--- a/frc971/wpilib/drivetrain_writer.cc
+++ b/frc971/wpilib/drivetrain_writer.cc
@@ -12,7 +12,7 @@
 
 void DrivetrainWriter::Write(
     const ::frc971::control_loops::DrivetrainQueue::Output &output) {
-  LOG_STRUCT(DEBUG, "will output", output);
+  AOS_LOG_STRUCT(DEBUG, "will output", output);
   left_controller0_->SetSpeed(SafeSpeed(reversed_left0_, output.left_voltage));
   right_controller0_->SetSpeed(
       SafeSpeed(reversed_right0_, output.right_voltage));
@@ -28,7 +28,7 @@
 }
 
 void DrivetrainWriter::Stop() {
-  LOG(WARNING, "drivetrain output too old\n");
+  AOS_LOG(WARNING, "drivetrain output too old\n");
   left_controller0_->SetDisabled();
   right_controller0_->SetDisabled();
 
diff --git a/frc971/wpilib/encoder_and_potentiometer.cc b/frc971/wpilib/encoder_and_potentiometer.cc
index 8fe8c25..ac1a4a0 100644
--- a/frc971/wpilib/encoder_and_potentiometer.cc
+++ b/frc971/wpilib/encoder_and_potentiometer.cc
@@ -21,10 +21,10 @@
 }
 
 void InterruptEncoderAndPotentiometer::Start() {
-  CHECK_NE(nullptr, encoder_);
-  CHECK_NE(nullptr, index_);
-  CHECK_NE(nullptr, potentiometer_);
-  CHECK_NE(0, priority_);
+  AOS_CHECK_NE(nullptr, encoder_);
+  AOS_CHECK_NE(nullptr, index_);
+  AOS_CHECK_NE(nullptr, potentiometer_);
+  AOS_CHECK_NE(0, priority_);
   thread_ = ::std::thread(::std::ref(*this));
 }
 
diff --git a/frc971/wpilib/gyro_interface.cc b/frc971/wpilib/gyro_interface.cc
index da0c01b..eeacfce 100644
--- a/frc971/wpilib/gyro_interface.cc
+++ b/frc971/wpilib/gyro_interface.cc
@@ -26,45 +26,47 @@
 bool GyroInterface::InitializeGyro() {
   uint32_t result;
   if (!DoTransaction(0x20000003, &result)) {
-    LOG(WARNING, "failed to start a self-check\n");
+    AOS_LOG(WARNING, "failed to start a self-check\n");
     return false;
   }
   if (result != 1) {
     // We might have hit a parity error or something and are now retrying, so
     // this isn't a very big deal.
-    LOG(INFO, "gyro unexpected initial response 0x%" PRIx32 "\n", result);
+    AOS_LOG(INFO, "gyro unexpected initial response 0x%" PRIx32 "\n", result);
   }
 
   // Wait for it to assert the fault conditions before reading them.
   ::std::this_thread::sleep_for(::std::chrono::milliseconds(50));
 
   if (!DoTransaction(0x20000000, &result)) {
-    LOG(WARNING, "failed to clear latched non-fault data\n");
+    AOS_LOG(WARNING, "failed to clear latched non-fault data\n");
     return false;
   }
-  LOG(DEBUG, "gyro dummy response is 0x%" PRIx32 "\n", result);
+  AOS_LOG(DEBUG, "gyro dummy response is 0x%" PRIx32 "\n", result);
 
   if (!DoTransaction(0x20000000, &result)) {
-    LOG(WARNING, "failed to read self-test data\n");
+    AOS_LOG(WARNING, "failed to read self-test data\n");
     return false;
   }
   if (ExtractStatus(result) != 2) {
-    LOG(WARNING, "gyro first value 0x%" PRIx32 " not self-test data\n", result);
+    AOS_LOG(WARNING, "gyro first value 0x%" PRIx32 " not self-test data\n",
+            result);
     return false;
   }
   if (ExtractErrors(result) != 0x7F) {
-    LOG(WARNING, "gyro first value 0x%" PRIx32 " does not have all errors\n",
-        result);
+    AOS_LOG(WARNING,
+            "gyro first value 0x%" PRIx32 " does not have all errors\n",
+            result);
     return false;
   }
 
   if (!DoTransaction(0x20000000, &result)) {
-    LOG(WARNING, "failed to clear latched self-test data\n");
+    AOS_LOG(WARNING, "failed to clear latched self-test data\n");
     return false;
   }
   if (ExtractStatus(result) != 2) {
-    LOG(WARNING, "gyro second value 0x%" PRIx32 " not self-test data\n",
-        result);
+    AOS_LOG(WARNING, "gyro second value 0x%" PRIx32 " not self-test data\n",
+            result);
     return false;
   }
 
@@ -88,21 +90,21 @@
 
   switch (gyro_->Transaction(to_send, to_receive, kBytes)) {
     case -1:
-      LOG(INFO, "SPI::Transaction failed\n");
+      AOS_LOG(INFO, "SPI::Transaction failed\n");
       return false;
     case kBytes:
       break;
     default:
-      LOG(FATAL, "SPI::Transaction returned something weird\n");
+      AOS_LOG(FATAL, "SPI::Transaction returned something weird\n");
   }
 
   memcpy(result, to_receive, kBytes);
   if (__builtin_parity(*result & 0xFFFF) != 1) {
-    LOG(INFO, "high byte parity failure\n");
+    AOS_LOG(INFO, "high byte parity failure\n");
     return false;
   }
   if (__builtin_parity(*result) != 1) {
-    LOG(INFO, "whole value parity failure\n");
+    AOS_LOG(INFO, "whole value parity failure\n");
     return false;
   }
 
@@ -115,13 +117,14 @@
   uint32_t response;
   while (true) {
     if (!DoTransaction(command, &response)) {
-      LOG(WARNING, "reading 0x%" PRIx8 " failed\n", address);
+      AOS_LOG(WARNING, "reading 0x%" PRIx8 " failed\n", address);
       continue;
     }
     if ((response & 0xEFE00000) != 0x4E000000) {
-      LOG(WARNING, "gyro read from 0x%" PRIx8
-                   " gave unexpected response 0x%" PRIx32 "\n",
-          address, response);
+      AOS_LOG(WARNING,
+              "gyro read from 0x%" PRIx8 " gave unexpected response 0x%" PRIx32
+              "\n",
+              address, response);
       continue;
     }
     return (response >> 5) & 0xFFFF;
diff --git a/frc971/wpilib/gyro_sender.cc b/frc971/wpilib/gyro_sender.cc
index b1edbd2..3a9f220 100644
--- a/frc971/wpilib/gyro_sender.cc
+++ b/frc971/wpilib/gyro_sender.cc
@@ -32,7 +32,7 @@
       gyro_reading_sender_(
           event_loop_->MakeSender<::frc971::sensors::GyroReading>(
               ".frc971.sensors.gyro_reading")) {
-  PCHECK(
+  AOS_PCHECK(
       system("ps -ef | grep '\\[spi0\\]' | awk '{print $1}' | xargs chrt -f -p "
              "33") == 0);
   event_loop_->set_name("Gyro");
@@ -53,12 +53,12 @@
       if (last_initialize_time_ + chrono::milliseconds(50) < monotonic_now) {
         if (gyro_.InitializeGyro()) {
           state_ = State::RUNNING;
-          LOG(INFO, "gyro initialized successfully\n");
+          AOS_LOG(INFO, "gyro initialized successfully\n");
 
           {
             auto message = uid_sender_.MakeMessage();
             message->uid = gyro_.ReadPartID();
-            LOG_STRUCT(INFO, "gyro ID", *message);
+            AOS_LOG_STRUCT(INFO, "gyro ID", *message);
             message.Send();
           }
         }
@@ -68,42 +68,42 @@
     case State::RUNNING: {
       const uint32_t result = gyro_.GetReading();
       if (result == 0) {
-        LOG(WARNING, "normal gyro read failed\n");
+        AOS_LOG(WARNING, "normal gyro read failed\n");
         return;
       }
       switch (gyro_.ExtractStatus(result)) {
         case 0:
-          LOG(WARNING, "gyro says data is bad\n");
+          AOS_LOG(WARNING, "gyro says data is bad\n");
           return;
         case 1:
           break;
         default:
-          LOG(WARNING, "gyro gave weird status 0x%" PRIx8 "\n",
-              gyro_.ExtractStatus(result));
+          AOS_LOG(WARNING, "gyro gave weird status 0x%" PRIx8 "\n",
+                  gyro_.ExtractStatus(result));
           return;
       }
       if (gyro_.ExtractErrors(result) != 0) {
         const uint8_t errors = gyro_.ExtractErrors(result);
         if (errors & (1 << 6)) {
-          LOG(WARNING, "gyro gave PLL error\n");
+          AOS_LOG(WARNING, "gyro gave PLL error\n");
         }
         if (errors & (1 << 5)) {
-          LOG(WARNING, "gyro gave quadrature error\n");
+          AOS_LOG(WARNING, "gyro gave quadrature error\n");
         }
         if (errors & (1 << 4)) {
-          LOG(WARNING, "gyro gave non-volatile memory error\n");
+          AOS_LOG(WARNING, "gyro gave non-volatile memory error\n");
         }
         if (errors & (1 << 3)) {
-          LOG(WARNING, "gyro gave volatile memory error\n");
+          AOS_LOG(WARNING, "gyro gave volatile memory error\n");
         }
         if (errors & (1 << 2)) {
-          LOG(WARNING, "gyro gave power error\n");
+          AOS_LOG(WARNING, "gyro gave power error\n");
         }
         if (errors & (1 << 1)) {
-          LOG(WARNING, "gyro gave continuous self-test error\n");
+          AOS_LOG(WARNING, "gyro gave continuous self-test error\n");
         }
         if (errors & 1) {
-          LOG(WARNING, "gyro gave unexpected self-test mode\n");
+          AOS_LOG(WARNING, "gyro gave unexpected self-test mode\n");
         }
         return;
       }
@@ -120,7 +120,7 @@
         angle_ += (new_angle + zero_offset_) * iterations;
         message->angle = angle_;
         message->velocity = angle_rate + zero_offset_ * kReadingRate;
-        LOG_STRUCT(DEBUG, "sending", *message);
+        AOS_LOG_STRUCT(DEBUG, "sending", *message);
         message.Send();
       } else {
         // TODO(brian): Don't break without 6 seconds of standing still before
@@ -130,7 +130,7 @@
         {
           message->angle = new_angle;
           message->velocity = angle_rate;
-          LOG_STRUCT(DEBUG, "collected while zeroing", *message);
+          AOS_LOG_STRUCT(DEBUG, "collected while zeroing", *message);
           message->angle = 0.0;
           message->velocity = 0.0;
           message.Send();
@@ -141,7 +141,7 @@
         if (joystick_state_fetcher_.get() && joystick_state_fetcher_->enabled &&
             zeroing_data_.full()) {
           zero_offset_ = -zeroing_data_.GetAverage();
-          LOG(INFO, "total zero offset %f\n", zero_offset_);
+          AOS_LOG(INFO, "total zero offset %f\n", zero_offset_);
           zeroed_ = true;
         }
       }
diff --git a/frc971/wpilib/interrupt_edge_counting.cc b/frc971/wpilib/interrupt_edge_counting.cc
index a06df8f..546e64b 100644
--- a/frc971/wpilib/interrupt_edge_counting.cc
+++ b/frc971/wpilib/interrupt_edge_counting.cc
@@ -55,8 +55,8 @@
       }
       current_value_ = hall_value;
     } else {
-      LOG(WARNING, "Detected spurious edge on %d.  Dropping it.\n",
-          input_->GetChannel());
+      AOS_LOG(WARNING, "Detected spurious edge on %d.  Dropping it.\n",
+              input_->GetChannel());
     }
   }
 }
@@ -93,7 +93,7 @@
   ::std::unique_lock<::aos::stl_mutex> mutex_guard(mutex_);
   for (auto &c : handlers_) {
     if (c->interrupt_count_changed()) {
-      LOG(WARNING, "got an interrupt while sampling. retrying\n");
+      AOS_LOG(WARNING, "got an interrupt while sampling. retrying\n");
       return false;
     }
   }
diff --git a/frc971/wpilib/interrupt_edge_counting.h b/frc971/wpilib/interrupt_edge_counting.h
index 50dc94d..160682c 100644
--- a/frc971/wpilib/interrupt_edge_counting.h
+++ b/frc971/wpilib/interrupt_edge_counting.h
@@ -46,8 +46,8 @@
   // Starts the thread running.
   // set_priority and set_mutex must be called first.
   void Start() {
-    CHECK_NE(nullptr, mutex_);
-    CHECK_NE(0, priority_);
+    AOS_CHECK_NE(nullptr, mutex_);
+    AOS_CHECK_NE(0, priority_);
     thread_ = ::std::thread(::std::ref(*this));
   }
 
diff --git a/frc971/wpilib/joystick_sender.cc b/frc971/wpilib/joystick_sender.cc
index a073066..31ecc6c 100644
--- a/frc971/wpilib/joystick_sender.cc
+++ b/frc971/wpilib/joystick_sender.cc
@@ -54,10 +54,10 @@
           if (ds->GetStickPOVCount(i) > 0) {
             new_state->joysticks[i].pov = ds->GetStickPOV(i, 0);
           }
-          LOG_STRUCT(DEBUG, "joystick_state", *new_state);
+          AOS_LOG_STRUCT(DEBUG, "joystick_state", *new_state);
         }
         if (!new_state.Send()) {
-          LOG(WARNING, "sending joystick_state failed\n");
+          AOS_LOG(WARNING, "sending joystick_state failed\n");
         }
       });
     }
diff --git a/frc971/wpilib/loop_output_handler_test.cc b/frc971/wpilib/loop_output_handler_test.cc
index 8a7e903..12c3f96 100644
--- a/frc971/wpilib/loop_output_handler_test.cc
+++ b/frc971/wpilib/loop_output_handler_test.cc
@@ -49,14 +49,14 @@
 
  protected:
   void Write(const LoopOutputHandlerTestOutput &output) override {
-    LOG_STRUCT(DEBUG, "output", output);
+    AOS_LOG_STRUCT(DEBUG, "output", output);
     ++count_;
     last_time_ = event_loop()->monotonic_now();
   }
 
   void Stop() override {
     stop_time_ = event_loop()->monotonic_now();
-    LOG(DEBUG, "Stopping\n");
+    AOS_LOG(DEBUG, "Stopping\n");
   }
 
  private:
@@ -92,7 +92,7 @@
 
           ++count;
         }
-        LOG(INFO, "Ping\n");
+        AOS_LOG(INFO, "Ping\n");
       });
 
   // Kick off the ping timer handler.
diff --git a/frc971/wpilib/pdp_fetcher.cc b/frc971/wpilib/pdp_fetcher.cc
index 98da761..aa85184 100644
--- a/frc971/wpilib/pdp_fetcher.cc
+++ b/frc971/wpilib/pdp_fetcher.cc
@@ -29,7 +29,7 @@
 
 void PDPFetcher::Loop(int iterations) {
   if (iterations != 1) {
-    LOG(DEBUG, "PDPFetcher skipped %d iterations\n", iterations - 1);
+    AOS_LOG(DEBUG, "PDPFetcher skipped %d iterations\n", iterations - 1);
   }
   auto message = pdp_values_sender_.MakeMessage();
   message->voltage = pdp_->GetVoltage();
@@ -38,9 +38,9 @@
   for (int i = 0; i < 16; ++i) {
     message->currents[i] = pdp_->GetCurrent(i);
   }
-  LOG_STRUCT(DEBUG, "got", *message);
+  AOS_LOG_STRUCT(DEBUG, "got", *message);
   if (!message.Send()) {
-    LOG(WARNING, "sending pdp values failed\n");
+    AOS_LOG(WARNING, "sending pdp values failed\n");
   }
 }
 
diff --git a/frc971/wpilib/sensor_reader.cc b/frc971/wpilib/sensor_reader.cc
index 209054b..63d3992 100644
--- a/frc971/wpilib/sensor_reader.cc
+++ b/frc971/wpilib/sensor_reader.cc
@@ -102,9 +102,9 @@
   period_ =
       pwm_trigger_ ? chrono::microseconds(5050) : chrono::microseconds(5000);
   if (pwm_trigger_) {
-    LOG(INFO, "Using PWM trigger and a 5.05 ms period\n");
+    AOS_LOG(INFO, "Using PWM trigger and a 5.05 ms period\n");
   } else {
-    LOG(INFO, "Defaulting to open loop pwm synchronization\n");
+    AOS_LOG(INFO, "Defaulting to open loop pwm synchronization\n");
   }
 
   // Now that we are configured, actually fill in the defaults.
@@ -117,7 +117,7 @@
 
 void SensorReader::Loop(const int iterations) {
   if (iterations != 1) {
-    LOG(WARNING, "SensorReader skipped %d iterations\n", iterations - 1);
+    AOS_LOG(WARNING, "SensorReader skipped %d iterations\n", iterations - 1);
   }
 
   const monotonic_clock::time_point monotonic_now =
@@ -126,7 +126,7 @@
   {
     auto new_state = robot_state_sender_.MakeMessage();
     ::frc971::wpilib::PopulateRobotState(new_state.get(), my_pid_);
-    LOG_STRUCT(DEBUG, "robot_state", *new_state);
+    AOS_LOG_STRUCT(DEBUG, "robot_state", *new_state);
     new_state.Send();
   }
   RunIteration();
@@ -136,8 +136,8 @@
   }
 
   if (pwm_trigger_) {
-    LOG(DEBUG, "PWM wakeup delta: %lld\n",
-        (monotonic_now - last_monotonic_now_).count());
+    AOS_LOG(DEBUG, "PWM wakeup delta: %lld\n",
+            (monotonic_now - last_monotonic_now_).count());
     last_monotonic_now_ = monotonic_now;
 
     monotonic_clock::time_point last_tick_timepoint = GetPWMStartTime();
diff --git a/frc971/wpilib/spi_rx_clearer.cc b/frc971/wpilib/spi_rx_clearer.cc
index dfe7e8b..245f073 100644
--- a/frc971/wpilib/spi_rx_clearer.cc
+++ b/frc971/wpilib/spi_rx_clearer.cc
@@ -11,18 +11,18 @@
 namespace wpilib {
 
 SpiRxClearer::SpiRxClearer() {
-  const int fd = PCHECK(open("/dev/mem", O_RDWR));
+  const int fd = AOS_PCHECK(open("/dev/mem", O_RDWR));
   void *const mmap_result = mmap(nullptr, kMappingSize, PROT_READ | PROT_WRITE,
                                  MAP_SHARED, fd, spi_peripheral_base_);
   if (mmap_result == MAP_FAILED) {
-    PLOG(FATAL, "mmap the SPI peripheral from /dev/mem failed\n");
+    AOS_PLOG(FATAL, "mmap the SPI peripheral from /dev/mem failed\n");
   }
-  PCHECK(close(fd));
+  AOS_PCHECK(close(fd));
   mapping_ = static_cast<volatile uint32_t *>(mmap_result);
 }
 
 SpiRxClearer::~SpiRxClearer() {
-  PCHECK(munmap(const_cast<uint32_t *>(mapping_), kMappingSize));
+  AOS_PCHECK(munmap(const_cast<uint32_t *>(mapping_), kMappingSize));
 }
 
 void SpiRxClearer::ClearRxFifo() {
@@ -34,9 +34,9 @@
       return;
     }
     // Read the next byte.
-    LOG(DEBUG, "Read from RX FIFO: %" PRIx32 "\n", ReadRegister(0x20));
+    AOS_LOG(DEBUG, "Read from RX FIFO: %" PRIx32 "\n", ReadRegister(0x20));
   }
-  LOG(FATAL, "Failed to clear the RX FIFO\n");
+  AOS_LOG(FATAL, "Failed to clear the RX FIFO\n");
 }
 
 }  // namespace wpilib
diff --git a/frc971/wpilib/wpilib_interface.cc b/frc971/wpilib/wpilib_interface.cc
index 851d809..4216e3b 100644
--- a/frc971/wpilib/wpilib_interface.cc
+++ b/frc971/wpilib/wpilib_interface.cc
@@ -23,7 +23,7 @@
   robot_state->voltage_battery = HAL_GetVinVoltage(&status);
 
   if (status != 0) {
-    LOG(FATAL, "Failed to get robot state: %d\n", status);
+    AOS_LOG(FATAL, "Failed to get robot state: %d\n", status);
   }
 }
 
diff --git a/frc971/wpilib/wpilib_robot_base.h b/frc971/wpilib/wpilib_robot_base.h
index ef3ec31..86672c4 100644
--- a/frc971/wpilib/wpilib_robot_base.h
+++ b/frc971/wpilib/wpilib_robot_base.h
@@ -28,7 +28,7 @@
       thread.join();
     }
 
-    LOG(ERROR, "Exiting WPILibRobot\n");
+    AOS_LOG(ERROR, "Exiting WPILibRobot\n");
 
     ::aos::Cleanup();
   }