cli_consumer.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2018 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "tools/util/cli_consumer.h"
  15. #include <iostream>
  16. namespace spvtools {
  17. namespace utils {
  18. void CLIMessageConsumer(spv_message_level_t level, const char*,
  19. const spv_position_t& position, const char* message) {
  20. switch (level) {
  21. case SPV_MSG_FATAL:
  22. case SPV_MSG_INTERNAL_ERROR:
  23. case SPV_MSG_ERROR:
  24. std::cerr << "error: line " << position.index << ": " << message
  25. << std::endl;
  26. break;
  27. case SPV_MSG_WARNING:
  28. std::cout << "warning: line " << position.index << ": " << message
  29. << std::endl;
  30. break;
  31. case SPV_MSG_INFO:
  32. std::cout << "info: line " << position.index << ": " << message
  33. << std::endl;
  34. break;
  35. default:
  36. break;
  37. }
  38. }
  39. } // namespace utils
  40. } // namespace spvtools