You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
2.0 KiB

  1. // base/kaldi-error.h
  2. // Copyright (c) 2021 Mobvoi Inc (Binbin Zhang)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef KALDI_BASE_KALDI_ERROR_H_
  16. #define KALDI_BASE_KALDI_ERROR_H_ 1
  17. #include "kaldi-types.h"
  18. namespace kaldi {
  19. #define KALDI_WARN \
  20. google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING).stream()
  21. #define KALDI_ERR \
  22. google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR).stream()
  23. #define KALDI_LOG \
  24. google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO).stream()
  25. #define KALDI_VLOG(v) VLOG(v)
  26. #define KALDI_ASSERT(condition) CHECK(condition)
  27. /***** PROGRAM NAME AND VERBOSITY LEVEL *****/
  28. /// Called by ParseOptions to set base name (no directory) of the executing
  29. /// program. The name is printed in logging code along with every message,
  30. /// because in our scripts, we often mix together the stderr of many programs.
  31. /// This function is very thread-unsafe.
  32. void SetProgramName(const char* basename);
  33. /// This is set by util/parse-options.{h,cc} if you set --verbose=? option.
  34. /// Do not use directly, prefer {Get,Set}VerboseLevel().
  35. extern kaldi::int32 g_kaldi_verbose_level;
  36. /// Get verbosity level, usually set via command line '--verbose=' switch.
  37. inline kaldi::int32 GetVerboseLevel() { return g_kaldi_verbose_level; }
  38. /// This should be rarely used, except by programs using Kaldi as library;
  39. /// command-line programs set the verbose level automatically from ParseOptions.
  40. inline void SetVerboseLevel(kaldi::int32 i) { g_kaldi_verbose_level = i; }
  41. } // namespace kaldi
  42. #endif // KALDI_BASE_KALDI_ERROR_H_