• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2  * Permission is hereby granted, free of charge, to any person obtaining a copy
3  * of this software and associated documentation files (the "Software"), to
4  * deal in the Software without restriction, including without limitation the
5  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6  * sell copies of the Software, and to permit persons to whom the Software is
7  * furnished to do so, subject to the following conditions:
8  *
9  * The above copyright notice and this permission notice shall be included in
10  * all copies or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
21 #include "uv_log.h"
22 #include "hilog/log.h"
23 
24 #include <stdarg.h>
25 
26 extern int HiLogPrintArgs(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
27     const char *fmt, va_list ap);
28 
convert_uv_log_level(enum uv__log_level level)29 LogLevel convert_uv_log_level(enum uv__log_level level) {
30   switch (level)
31   {
32     case UV_DEBUG:
33       return LOG_DEBUG;
34     case UV_INFO:
35       return LOG_INFO;
36     case UV_WARN:
37       return LOG_WARN;
38     case UV_ERROR:
39       return LOG_ERROR;
40     case UV_FATAL:
41       return LOG_FATAL;
42     default:
43       return LOG_LEVEL_MIN;
44   }
45 }
46 
uv__log_impl(enum uv__log_level level,const char * fmt,...)47 int uv__log_impl(enum uv__log_level level, const char *fmt, ...) {
48   va_list args;
49   va_start(args, fmt);
50   int ret = HiLogPrintArgs(LOG_TYPE_MIN, convert_uv_log_level(level), 0xD003900, "UV", fmt, args);
51   va_end(args);
52   return ret;
53 }
54