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.

58 lines
2.1 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. #ifndef FST_LOG_H_
  18. #pragma message("fst/log.h is included")
  19. #include "fst/log.h"
  20. #endif
  21. namespace kaldi {
  22. #define KALDI_WARN \
  23. google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING).stream()
  24. #define KALDI_ERR \
  25. google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR).stream()
  26. #define KALDI_LOG \
  27. google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO).stream()
  28. #define KALDI_VLOG(v) VLOG(v)
  29. #define KALDI_ASSERT(condition) CHECK(condition)
  30. /***** PROGRAM NAME AND VERBOSITY LEVEL *****/
  31. /// Called by ParseOptions to set base name (no directory) of the executing
  32. /// program. The name is printed in logging code along with every message,
  33. /// because in our scripts, we often mix together the stderr of many programs.
  34. /// This function is very thread-unsafe.
  35. void SetProgramName(const char* basename);
  36. /// This is set by util/parse-options.{h,cc} if you set --verbose=? option.
  37. /// Do not use directly, prefer {Get,Set}VerboseLevel().
  38. extern kaldi::int32 g_kaldi_verbose_level;
  39. /// Get verbosity level, usually set via command line '--verbose=' switch.
  40. inline kaldi::int32 GetVerboseLevel() { return g_kaldi_verbose_level; }
  41. /// This should be rarely used, except by programs using Kaldi as library;
  42. /// command-line programs set the verbose level automatically from ParseOptions.
  43. inline void SetVerboseLevel(kaldi::int32 i) { g_kaldi_verbose_level = i; }
  44. } // namespace kaldi
  45. #endif // KALDI_BASE_KALDI_ERROR_H_