MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sys_log

Function sys_log

components/lwp/lwp_syscall.c:4409–4439  ·  view source on GitHub ↗

* @brief Logs a message to the system logging mechanism. * * This system call writes a log message to the system log for diagnostic or informational purposes. * The message is specified by the `log` parameter, and its size is given by the `size` parameter. * The logging mechanism is typically used for tracking system events, debugging, or reporting errors. * * @param[in] log A pointer to t

Source from the content-addressed store, hash-verified

4407 * logging system is properly initialized before invoking this function.
4408 */
4409sysret_t sys_log(const char* log, int size)
4410{
4411 char *klog = RT_NULL;
4412 rt_device_t console = RT_NULL;
4413
4414 if (!lwp_user_accessable((void *)log, size))
4415 return -EFAULT;
4416
4417 klog = kmem_get(size);
4418 if (klog == RT_NULL)
4419 {
4420 return -ENOMEM;
4421 }
4422
4423 if (lwp_get_from_user((void *)klog, (void *)log, size) != size)
4424 {
4425 kmem_put(klog);
4426 return -EINVAL;
4427 }
4428
4429 console = rt_console_get_device();
4430
4431 if (console && __sys_log_enable)
4432 {
4433 rt_device_write(console, -1, klog, size);
4434 }
4435
4436 kmem_put(klog);
4437
4438 return 0;
4439}
4440
4441/**
4442 * @brief Retrieves information about a file or directory.

Callers

nothing calls this directly

Calls 6

lwp_user_accessableFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
rt_console_get_deviceFunction · 0.85
rt_device_writeFunction · 0.85

Tested by

no test coverage detected