From version < 13.2 >
edited by SandrineAvakian
on 2017/02/22 16:28
To version < 14.1 >
edited by Admin Admin
on 2017/02/23 11:04
< >
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.SandrineAvakian
1 +xwiki:XWiki.BenjaminReis
Content
... ... @@ -45,22 +45,84 @@
45 45  
46 46  This will make the liblinphone logs to call your_log_handler and so be processes as a log from your app.
47 47  
48 -You can set the liblinphone log level by using the following functions :
48 +You can set the liblinphone log level by using the functions documented [[here>>http://linphone.org/docs/liblinphone/group__initializing.html#ga685b79d92af0184dbeac46df14bf4705]].
49 49  
50 -{{code language="C"}}
51 -/**
52 - * Define the minimum level for logging.
53 - *
54 - * @param loglevel Minimum level for logging messages.
55 -**/
56 -LINPHONE_PUBLIC void linphone_core_set_log_level(OrtpLogLevel loglevel);
50 +== IOS log handler for liblinphone ==
57 57  
58 -/**
59 - * Activate all log level greater or equal than specified level argument.
60 -**/
61 -ORTP_PUBLIC void ortp_set_log_level(const char *domain, OrtpLogLevel level);
52 +Once you set your log handler you need to process liblinphone log in order to incorporate them into your app logs.
53 +
54 +Here is a little example on how to manage liblinphone log into an IOS app :
55 +
56 +{{code language="Objective-C"}}
57 +void linphone_iphone_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) {
58 + NSString *format = [[NSString alloc] initWithUTF8String:fmt];
59 + NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args];
60 +
61 + if (!domain)
62 + domain = "lib";
63 + // since \r are interpreted like \n, avoid double new lines when logging network packets (belle-sip)
64 + // output format is like: I/ios/some logs. We truncate domain to **exactly** DOMAIN_SIZE characters to have
65 + // fixed-length aligned logs
66 +
67 + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) {
68 + os_log_t log = os_log_create("subsystem", "Notice");
69 + os_log_type_t type = OS_LOG_TYPE_INFO;
70 + switch (lev) {
71 + case ORTP_FATAL:
72 + type = OS_LOG_TYPE_FAULT;
73 + log = os_log_create("subsystem", "Fatal");
74 + break;
75 + case ORTP_ERROR:
76 + type = OS_LOG_TYPE_ERROR;
77 + log = os_log_create("subsystem", "Error");
78 + break;
79 + case ORTP_WARNING:
80 + type = OS_LOG_TYPE_DEFAULT;
81 + log = os_log_create("subsystem", "Warning");
82 + break;
83 + case ORTP_MESSAGE:
84 + type = OS_LOG_TYPE_INFO;
85 + log = os_log_create("subsystem", "Notice");
86 + break;
87 + case ORTP_DEBUG:
88 + case ORTP_TRACE:
89 + type = OS_LOG_TYPE_INFO;
90 + log = os_log_create("subsystem", "Debug");
91 + break;
92 + case ORTP_LOGLEV_END:
93 + return;
94 + }
95 + os_log_with_type(log, type, "%{public}s/%{public}s", domain,
96 + [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String);
97 + } else {
98 + int lvl = ASL_LEVEL_NOTICE;
99 + switch (lev) {
100 + case ORTP_FATAL:
101 + lvl = ASL_LEVEL_CRIT;
102 + break;
103 + case ORTP_ERROR:
104 + lvl = ASL_LEVEL_ERR;
105 + break;
106 + case ORTP_WARNING:
107 + lvl = ASL_LEVEL_WARNING;
108 + break;
109 + case ORTP_MESSAGE:
110 + lvl = ASL_LEVEL_NOTICE;
111 + break;
112 + case ORTP_DEBUG:
113 + case ORTP_TRACE:
114 + lvl = ASL_LEVEL_INFO;
115 + break;
116 + case ORTP_LOGLEV_END:
117 + return;
118 + }
119 + asl_log(NULL, NULL, lvl, "%*.*s/%s", DOMAIN_SIZE, DOMAIN_SIZE, domain,
120 + [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String);
121 + }
122 +}
62 62  {{/code}}
63 63  
125 +
64 64  = Full ipv6 support =
65 65  
66 66  {{info}}