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.

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