xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <errno.h> |
| 5 | #include <string.h> |
xf.li | 4364377 | 2024-03-04 19:39:53 -0800 | [diff] [blame] | 6 | #include "lynq_deflog.h" |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 7 | |
| 8 | int main(int argc, char *argv[]) |
| 9 | { |
| 10 | int err, value; |
| 11 | int cmdIdx = 0; |
| 12 | int ret = 0; |
| 13 | int i = 0; |
| 14 | char operator[10]; |
| 15 | int opt = 0; |
xf.li | 4364377 | 2024-03-04 19:39:53 -0800 | [diff] [blame] | 16 | const char * module_name = "MBTK_QL_TEST"; |
| 17 | log_level_enum *level = -1; |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 18 | |
| 19 | lynq_log_configuration_init("MBTK_QL_TEST"); |
| 20 | |
| 21 | while(1) |
| 22 | { |
| 23 | |
| 24 | printf("=========log========\n" |
| 25 | "\t 0 lynq_syslog_set_file_size\n" |
| 26 | "\t 1 lynq_syslog_get_file_size\n" |
| 27 | "\t 2 lynq_syslog_set_file_rotate\n" |
| 28 | "\t 3 lynq_syslog_get_file_rotate\n" |
xf.li | 4364377 | 2024-03-04 19:39:53 -0800 | [diff] [blame] | 29 | "\t 4 lynq_set_log_level\n" |
| 30 | "\t 5 lynq_get_log_level\n" |
xf.li | 4bd9ee4 | 2024-04-13 01:31:44 -0700 | [diff] [blame] | 31 | "\t 6 lynq_notify_recalc_log_level\n" |
| 32 | "\t 7 test write log\n" |
| 33 | "\t 8 EXIT \n" |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 34 | "=========================\n"); |
xf.li | 4364377 | 2024-03-04 19:39:53 -0800 | [diff] [blame] | 35 | |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 36 | fflush(stdin); |
| 37 | fgets(operator, sizeof(operator), stdin); |
| 38 | opt = atoi(operator); |
| 39 | |
| 40 | switch(opt) |
| 41 | { |
| 42 | case 0://"lynq_syslog_set_file_size" |
| 43 | { |
| 44 | //fgets(arg_string, MAX_INPUT, stdin); |
| 45 | printf("please input size:\n"); |
| 46 | scanf("%d", &value); |
| 47 | printf("Input value is %d\n",value); |
| 48 | ret = lynq_syslog_set_file_size(value); |
| 49 | if(ret < 0) |
| 50 | { |
| 51 | printf("lynq_syslog_set_file_size failed, ret=%d\n", ret); |
| 52 | } |
| 53 | |
| 54 | break; |
| 55 | } |
| 56 | case 1://"lynq_syslog_get_file_size" |
| 57 | { |
| 58 | //ret = demo_lynq_syslog_get_file_size(); |
| 59 | ret = lynq_syslog_get_file_size(); |
| 60 | printf("lynq_syslog_get_file_size ret:%d!\n", ret); |
| 61 | |
| 62 | break; |
| 63 | } |
| 64 | case 2://"lynq_syslog_set_file_rotate" |
| 65 | { |
| 66 | printf("please input count:\n"); |
| 67 | scanf("%d", &value); |
| 68 | printf("Input value is %d\n",value); |
| 69 | ret = lynq_syslog_set_file_rotate(value); |
| 70 | if(ret < 0) |
| 71 | { |
| 72 | printf("lynq_syslog_set_file_rotate failed, ret=%d\n", ret); |
| 73 | } |
| 74 | |
| 75 | break; |
| 76 | } |
| 77 | case 3://"lynq_syslog_get_file_rotate" |
| 78 | { |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 79 | ret = lynq_syslog_get_file_rotate(); |
| 80 | printf("lynq_syslog_get_file_rotate ret:%d!\n", ret); |
| 81 | |
| 82 | break; |
| 83 | } |
xf.li | 4364377 | 2024-03-04 19:39:53 -0800 | [diff] [blame] | 84 | case 4://"lynq_set_log_level" |
| 85 | { |
| 86 | printf("please input level:\n"); |
| 87 | scanf("%d", &value); |
| 88 | ret = lynq_set_log_level(module_name, value); |
| 89 | printf("lynq_set_log_level ret:%d!\n", ret); |
| 90 | |
| 91 | break; |
| 92 | } |
| 93 | case 5://"lynq_get_log_level" |
| 94 | { |
| 95 | ret = lynq_get_log_level(module_name, &level); |
| 96 | printf("lynq_get_log_level ret:%d, level:%d!\n", ret, level); |
| 97 | |
| 98 | break; |
| 99 | } |
| 100 | case 6://test write log |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 101 | { |
xf.li | 4bd9ee4 | 2024-04-13 01:31:44 -0700 | [diff] [blame] | 102 | ret = lynq_notify_recalc_log_level(0); |
| 103 | printf("lynq_notify_recalc_log_level ret: %d!\n", ret); |
| 104 | break; |
| 105 | } |
| 106 | case 7://test write log |
| 107 | { |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 108 | puts(lynq_read_log_version()); |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 109 | for(i=0;i<10;i++) |
| 110 | { |
| 111 | LYVERBLOG("LYNQ: Test LYVERBLOG\n"); |
| 112 | LYERRLOG("LYNQ: Test LYERRLOG\n"); |
| 113 | LYWARNLOG("LYNQ: Test LYWARNLOG\n"); |
| 114 | LYINFLOG("LYNQ: Test LYINFLOG\n"); |
| 115 | LYDBGLOG("LYNQ: Test LYDBGLOG\n"); |
b.liu | f37bd33 | 2024-03-18 13:51:24 +0800 | [diff] [blame] | 116 | lynq_log_global_output(LOG_VERBOSE, "LOG_VERBOSE test"); |
| 117 | lynq_log_global_output(LOG_ERROR, "LOG_ERROR test"); |
| 118 | lynq_log_global_output(LOG_WARNING, "LOG_WARNING test"); |
| 119 | lynq_log_global_output(LOG_INFO, "LOG_INFO test"); |
| 120 | lynq_log_global_output(LOG_DEBUG, "LOG_DEBUG test"); |
| 121 | lynq_log_global_output(LOG_UNSET, "LOG_UNSET test"); |
| 122 | lynq_log_global_output(LOG_LEVEL_MAX, "LOG_LEVEL_MAX test"); |
xf.li | 4bd9ee4 | 2024-04-13 01:31:44 -0700 | [diff] [blame] | 123 | lynq_log_debug("LYNQ: test lynq_log_debug"); |
| 124 | lynq_log_verbose("LYNQ: test lynq_log_verbose"); |
| 125 | lynq_log_error("LYNQ: test lynq_log_error"); |
| 126 | lynq_log_info("LYNQ: test lynq_log_info"); |
| 127 | lynq_log_warning("LYNQ: test lynq_log_warning"); |
xf.li | 44e0869 | 2024-01-30 01:54:44 -0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | printf("test write log end\n"); |
| 131 | |
| 132 | break; |
| 133 | } |
| 134 | default://EXIT |
| 135 | { |
| 136 | printf("break\n"); |
| 137 | return 0; |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |