dsp_common.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2022 Alibaba Group. All rights reserved.
  3. * License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. * not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #include "dsp_common.h"
  19. int log_level = CSI_DSP_LOG_INFO;
  20. int pid = 0;
  21. static int getLogLevel()
  22. {
  23. pid = getpid();
  24. char *env = getenv("LIGHT_DSP_LOG_LEVEL");
  25. if (env == NULL)
  26. return CSI_DSP_LOG_ERROR;
  27. else
  28. {
  29. int level = atoi(env);
  30. if (level >= CSI_DSP_LOG_MAX || level < CSI_DSP_LOG_QUIET)
  31. return CSI_DSP_LOG_ERROR;
  32. else
  33. return level;
  34. }
  35. }
  36. void dsp_InitEnv()
  37. {
  38. log_level = getLogLevel();
  39. }