Including dlog_[v]print_{dotnet,native} interfaces.
Change-Id: Ie1692f8302dd42fa9d7f399b158c3190137406a9
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
enable_system=0
enable_radio=0
enable_apps=0
+enable_dotnet_api=0
+enable_native_api=0
# remove the backup redirection from apps to main that exists in the regular config
enable_radio=1
enable_system=1
enable_apps=1
+
# enable_kmsg = 1 # DOESN'T WORK! KMSG is not a libdlog-populated buffer. See below for `handle_kmsg` instead.
enable_critical=1
+# these two are not full buffers, they are just log sinks that redirect to the 'apps' buffer.
+enable_dotnet_api=1
+enable_native_api=1
+
# Debugmode - whether write platform debug log or not
# If disabled, logs at priority levels DEBUG and below - this means also VERBOSE - are completely dropped
debugmode=1
/**
+ * @brief Sends log with priority and tag
+ * @details The same as 'dlog_print' except controlled by 'enable_dotnet_api'
+ * instead of 'enable_apps'
+ * @since_tizen 7.5
+ * @param[in] prio priority level of type #log_priority
+ * @param[in] tag tag - a null-terminated string
+ * @param[in] fmt format string - same as printf
+ * @return On success, the function returns the number of bytes written.
+ * On error, a negative errno-style error code
+ * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
+ * @pre none
+ * @post none
+ * @see dlog_vprint_dotnet
+ * @see dlog_print
+ */
+int dlog_print_dotnet(log_priority prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+
+/**
+ * @brief Sends log with priority and tag
+ * @details The same as 'dlog_print' except controlled by 'enable_native_api'
+ * instead of 'enable_apps'
+ * @since_tizen 7.5
+ * @param[in] prio priority level of type #log_priority
+ * @param[in] tag tag - a null-terminated string
+ * @param[in] fmt format string - same as printf
+ * @return On success, the function returns the number of bytes written.
+ * On error, a negative errno-style error code
+ * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
+ * @pre none
+ * @post none
+ * @see dlog_vprint_native
+ * @see dlog_print
+ */
+int dlog_print_native(log_priority prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+
+
+/**
+ * @brief Sends log with priority, tag, and va_list.
+ * @details The same as 'dlog_vprint' except controlled by 'enable_dotnet_api'
+ * instead of 'enable_apps'
+ * @since_tizen 7.5
+ * @param[in] prio priority level of type #log_priority
+ * @param[in] tag tag - a null-terminated string
+ * @param[in] fmt format string - same as printf
+ * @param[in] ap va_list
+ * @return On success, the function returns the number of bytes written.
+ * On error, a negative errno-style error code
+ * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
+ * @pre none
+ * @post none
+ * @see dlog_print_dotnet
+ * @see dlog_vprint
+ */
+int dlog_vprint_dotnet(log_priority prio, const char *tag, const char *fmt, va_list ap);
+
+/**
+ * @brief Sends log with priority, tag, and va_list.
+ * @details The same as 'dlog_vprint' except controlled by 'enable_native_api'
+ * instead of 'enable_apps'
+ * @since_tizen 7.5
+ * @param[in] prio priority level of type #log_priority
+ * @param[in] tag tag - a null-terminated string
+ * @param[in] fmt format string - same as printf
+ * @param[in] ap va_list
+ * @return On success, the function returns the number of bytes written.
+ * On error, a negative errno-style error code
+ * @retval #DLOG_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DLOG_ERROR_NOT_PERMITTED Operation not permitted
+ * @pre none
+ * @post none
+ * @see dlog_print_native
+ * @see dlog_vprint
+ */
+int dlog_vprint_native(log_priority prio, const char *tag, const char *fmt, va_list ap);
+
+
+/**
* @}
*/
* other LOG_ID_XYZ constants and have to be handled separately. The upside is
* that the requirement to hardcode them to redirect to a core buffer means that
* we can keep the existence of these buffers to a handful of files as logs will
- * become basically undistinguishable to other programs once they get sent. */
+ * become basically undistinguishable to other programs once they get sent.
+ *
+ * Also, the same as existing buffers, 'dotnet' and 'native' are just handles
+ * and don't actually mean anything to dlog (i.e. logs can end up there from any
+ * program, not just .NET/native programs), though of course whoever uses these
+ * sinks will likely want to use them accordingly. */
-#define SINKS_MAX (LOG_ID_MAX)
+#define SINK_DOTNET (LOG_ID_MAX)
+#define SINK_NATIVE (LOG_ID_MAX + 1)
+#define SINKS_MAX (LOG_ID_MAX + 2)
return ret;
}
+EXPORT_API int dlog_vprint_dotnet(log_priority prio, const char *tag, const char *fmt, va_list ap)
+{
+ return __write_to_log(SINK_DOTNET, prio, tag, fmt, ap, false, false);
+}
+
+EXPORT_API int dlog_print_dotnet(log_priority prio, const char *tag, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ int ret = dlog_vprint_dotnet(prio, tag, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+EXPORT_API int dlog_vprint_native(log_priority prio, const char *tag, const char *fmt, va_list ap)
+{
+ return __write_to_log(SINK_NATIVE, prio, tag, fmt, ap, false, false);
+}
+
+EXPORT_API int dlog_print_native(log_priority prio, const char *tag, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ int ret = dlog_vprint_native(prio, tag, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
/**
* @brief Finalize DLog
* @details Finalizes and deallocates the library
ret = (dlog_error_e) __dlog_critical_print(params->buffer, params->priority, params->tag, "%s", params->msg);
else if (params->secure)
ret = (dlog_error_e) __dlog_sec_print(params->buffer, params->priority, params->tag, "%s", params->msg);
+ else if (params->buffer == SINK_DOTNET)
+ ret = (dlog_error_e) dlog_print_dotnet( /* apps */ params->priority, params->tag, "%s", params->msg);
+ else if (params->buffer == SINK_NATIVE)
+ ret = (dlog_error_e) dlog_print_native( /* apps */ params->priority, params->tag, "%s", params->msg);
else
ret = (dlog_error_e) __dlog_print(params->buffer, params->priority, params->tag, "%s", params->msg);
if (ret < 0) {
"\t \tfirst letter is enough; defaults to Info\n"
"\t-b buffer \tone of {main, system, radio, apps}\n"
"\t \tdefaults to apps\n"
- "\t-b sink \t(currently none available)\n"
+ "\t-b sink \tone of {dotnet_api, native_api}\n"
"\t \textra sinks that use different dlog interfaces\n"
"\t-t tag \ta short identification string for identification and filtering purposes\n"
"\t \tcan be anything, defaults to DLOG_SEND\n"
[LOG_ID_APPS ] = { .name = "apps" , .core = true, .platform = false, .extra_sink = false, .sink_redirect = LOG_ID_APPS },
[LOG_ID_KMSG ] = { .name = "kmsg" , .core = false, .platform = false, .extra_sink = false, .sink_redirect = LOG_ID_KMSG },
[LOG_ID_SYSLOG] = { .name = "syslog" , .core = false, .platform = false, .extra_sink = false, .sink_redirect = LOG_ID_SYSLOG },
+ [SINK_DOTNET ] = { .name = "dotnet_api", .core = false, .platform = false, .extra_sink = true, .sink_redirect = LOG_ID_APPS },
+ [SINK_NATIVE ] = { .name = "native_api", .core = false, .platform = false, .extra_sink = true, .sink_redirect = LOG_ID_APPS },
};
bool is_buffer_valid(log_id_t id)
"enable_apps=1",
"enable_kmsg=1",
"enable_syslog=1",
+ "enable_dotnet_api=1",
+ "enable_native_api=1",
};
struct parsed_params pp;
[ "$(dlogutil -d DLOGSEND_SIGPIPE_TEST | wc -l)" -eq 2 ] && ok || fail
fi
+dlogutil -c
+
+LOG_DETAILS="testing if dlogutil rejects dotnet"
+dlogutil -db dotnet_api && fail || ok
+
+LOG_DETAILS="testing if dlogutil rejects native"
+dlogutil -db native_api && fail || ok
+
+LOG_DETAILS="testing if dotnet redirects to regular apps (1/2)"
+dlogsend -b dotnet_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+
+LOG_DETAILS="testing if dotnet redirects to regular apps (2/2)"
+dlogsend -c 6 -b dotnet_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 7 ] && ok || fail
+
+LOG_DETAILS="testing if native redirects to regular apps (1/2)"
+dlogsend -b native_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 8 ] && ok || fail
+
+LOG_DETAILS="testing if native redirects to regular apps (2/2)"
+dlogsend -c 6 -b native_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 14 ] && ok || fail
+
+dlogutil -c
+LOG_DETAILS="testing if blocking dotnet and regular apps is separate (1/4)"
+dlogctl -b apps --enable
+dlogctl -b dotnet_api --disable
+dlogsend -b dotnet_api "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 0 ] && ok || fail
+LOG_DETAILS="testing if blocking dotnet and regular apps is separate (2/4)"
+dlogsend -b apps "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+LOG_DETAILS="testing if blocking dotnet and regular apps is separate (3/4)"
+dlogctl -b apps --disable
+dlogctl -b dotnet_api --enable
+dlogsend -b dotnet_api "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+LOG_DETAILS="testing if blocking dotnet and regular apps is separate (4/4)"
+dlogsend -b apps "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+
+
+dlogutil -c
+LOG_DETAILS="testing if blocking native and regular apps is separate (1/4)"
+dlogctl -b apps --enable
+dlogctl -b native_api --disable
+dlogsend -b native_api "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 0 ] && ok || fail
+LOG_DETAILS="testing if blocking native and regular apps is separate (2/4)"
+dlogsend -b apps "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+LOG_DETAILS="testing if blocking native and regular apps is separate (3/4)"
+dlogctl -b apps --disable
+dlogctl -b native_api --enable
+dlogsend -b native_api "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+LOG_DETAILS="testing if blocking native and regular apps is separate (4/4)"
+dlogsend -b apps "TEST"
+[ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+
# put 100 log entries in the "main" buffer
dlogutil -c
test_libdlog 100