mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
parent
73adee82bf
commit
117ed2071b
8 changed files with 36 additions and 34 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <systemd/sd-bus.h>
|
#include <systemd/sd-bus.h>
|
||||||
#include "shl_dlist.h"
|
#include "shl_dlist.h"
|
||||||
|
#include "shl_log.h"
|
||||||
|
|
||||||
#ifndef CTL_CTL_H
|
#ifndef CTL_CTL_H
|
||||||
#define CTL_CTL_H
|
#define CTL_CTL_H
|
||||||
|
@ -123,34 +124,6 @@ extern int cli_max_sev;
|
||||||
void cli_printv(const char *fmt, va_list args);
|
void cli_printv(const char *fmt, va_list args);
|
||||||
void cli_printf(const char *fmt, ...);
|
void cli_printf(const char *fmt, ...);
|
||||||
|
|
||||||
enum {
|
|
||||||
#ifndef LOG_FATAL
|
|
||||||
LOG_FATAL = 0,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_ALERT
|
|
||||||
LOG_ALERT = 1,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_CRITICAL
|
|
||||||
LOG_CRITICAL = 2,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_ERROR
|
|
||||||
LOG_ERROR = 3,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_WARNING
|
|
||||||
LOG_WARNING = 4,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_NOTICE
|
|
||||||
LOG_NOTICE = 5,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_INFO
|
|
||||||
LOG_INFO = 6,
|
|
||||||
#endif
|
|
||||||
#ifndef LOG_DEBUG
|
|
||||||
LOG_DEBUG = 7,
|
|
||||||
#endif
|
|
||||||
LOG_SEV_NUM,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define cli_log(_fmt, ...) \
|
#define cli_log(_fmt, ...) \
|
||||||
cli_printf(_fmt "\n", ##__VA_ARGS__)
|
cli_printf(_fmt "\n", ##__VA_ARGS__)
|
||||||
#define cli_log_fn(_fmt, ...) \
|
#define cli_log_fn(_fmt, ...) \
|
||||||
|
|
|
@ -703,7 +703,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
puts(PACKAGE_STRING);
|
puts(PACKAGE_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
case ARG_LOG_LEVEL:
|
case ARG_LOG_LEVEL:
|
||||||
cli_max_sev = atoi(optarg);
|
cli_max_sev = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case ARG_AUDIO:
|
case ARG_AUDIO:
|
||||||
gst_audio_en = atoi(optarg);
|
gst_audio_en = atoi(optarg);
|
||||||
|
|
|
@ -514,7 +514,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
puts(PACKAGE_STRING);
|
puts(PACKAGE_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
case ARG_LOG_LEVEL:
|
case ARG_LOG_LEVEL:
|
||||||
cli_max_sev = atoi(optarg);
|
cli_max_sev = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -818,7 +818,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
puts(PACKAGE_STRING);
|
puts(PACKAGE_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
case ARG_LOG_LEVEL:
|
case ARG_LOG_LEVEL:
|
||||||
log_max_sev = atoi(optarg);
|
log_max_sev = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case ARG_LOG_TIME:
|
case ARG_LOG_TIME:
|
||||||
log_init_time();
|
log_init_time();
|
||||||
|
|
|
@ -99,7 +99,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
puts(PACKAGE_STRING);
|
puts(PACKAGE_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
case ARG_LOG_LEVEL:
|
case ARG_LOG_LEVEL:
|
||||||
log_max_sev = atoi(optarg);
|
log_max_sev = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case ARG_LOG_TIME:
|
case ARG_LOG_TIME:
|
||||||
log_init_time();
|
log_init_time();
|
||||||
|
|
|
@ -238,3 +238,30 @@ void log_llog(void *data,
|
||||||
{
|
{
|
||||||
log_submit(file, line, func, subs, sev, format, args);
|
log_submit(file, line, func, subs, sev, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int log_parse_arg(char *optarg)
|
||||||
|
{
|
||||||
|
int log_max_sev;
|
||||||
|
if(!strcasecmp(optarg, "fatal")) {
|
||||||
|
log_max_sev = LOG_FATAL;
|
||||||
|
} else if(!strcasecmp(optarg, "alert")) {
|
||||||
|
log_max_sev = LOG_ALERT;
|
||||||
|
} else if(!strcasecmp(optarg, "critical")) {
|
||||||
|
log_max_sev = LOG_CRITICAL;
|
||||||
|
} else if(!strcasecmp(optarg, "error")) {
|
||||||
|
log_max_sev = LOG_ERROR;
|
||||||
|
} else if(!strcasecmp(optarg, "warning")) {
|
||||||
|
log_max_sev = LOG_WARNING;
|
||||||
|
} else if(!strcasecmp(optarg, "notice")) {
|
||||||
|
log_max_sev = LOG_NOTICE;
|
||||||
|
} else if(!strcasecmp(optarg, "info")) {
|
||||||
|
log_max_sev = LOG_INFO;
|
||||||
|
} else if(!strcasecmp(optarg, "debug")) {
|
||||||
|
log_max_sev = LOG_DEBUG;
|
||||||
|
} else if(!strcasecmp(optarg, "trace")) {
|
||||||
|
log_max_sev = LOG_TRACE;
|
||||||
|
} else {
|
||||||
|
log_max_sev = atoi(optarg);
|
||||||
|
}
|
||||||
|
return log_max_sev;
|
||||||
|
}
|
||||||
|
|
|
@ -116,6 +116,8 @@ void log_llog(void *data,
|
||||||
const char *format,
|
const char *format,
|
||||||
va_list args);
|
va_list args);
|
||||||
|
|
||||||
|
int log_parse_arg(char *optarg);
|
||||||
|
|
||||||
static inline __attribute__((format(printf, 2, 3)))
|
static inline __attribute__((format(printf, 2, 3)))
|
||||||
void log_dummyf(unsigned int sev, const char *format, ...)
|
void log_dummyf(unsigned int sev, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -502,7 +502,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
puts(PACKAGE_STRING);
|
puts(PACKAGE_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
case ARG_LOG_LEVEL:
|
case ARG_LOG_LEVEL:
|
||||||
log_max_sev = atoi(optarg);
|
log_max_sev = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case ARG_LOG_TIME:
|
case ARG_LOG_TIME:
|
||||||
log_init_time();
|
log_init_time();
|
||||||
|
@ -512,7 +512,7 @@ static int parse_argv(int argc, char *argv[])
|
||||||
arg_wpa_bindir = optarg;
|
arg_wpa_bindir = optarg;
|
||||||
break;
|
break;
|
||||||
case ARG_WPA_LOGLEVEL:
|
case ARG_WPA_LOGLEVEL:
|
||||||
arg_wpa_loglevel = atoi(optarg);
|
arg_wpa_loglevel = log_parse_arg(optarg);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue