mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 05:23:35 +08:00
POSIX: Improved logging
The warnx and warn calls map to PX4_WARN. Calls to errx or err genrtate a compile error. The px4_log.h file implements a new log format: For DEBUG and INFO: <level> <msg> For ERROR and WARN: <level> <msg> (file filepath line linenum) The verbosity can be changed by setting the macro to use either linux_log or linux_log_verbose in px4_log.h Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -71,7 +71,7 @@ static void *timer_handler(void *data)
|
||||
usleep(td->ts.tv_nsec/1000);
|
||||
sem_post(&(td->sem));
|
||||
|
||||
PX4_DEBUG("timer_handler: Timer expired\n");
|
||||
PX4_DEBUG("timer_handler: Timer expired");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ inline bool valid_fd(int fd)
|
||||
|
||||
int px4_open(const char *path, int flags, ...)
|
||||
{
|
||||
printf("px4_open\n");
|
||||
PX4_DEBUG("px4_open");
|
||||
VDev *dev = VDev::getDev(path);
|
||||
int ret = 0;
|
||||
int i;
|
||||
@@ -103,7 +103,7 @@ int px4_open(const char *path, int flags, ...)
|
||||
va_end(p);
|
||||
|
||||
// Create the file
|
||||
warnx("Creating virtual file %s\n", path);
|
||||
PX4_DEBUG("Creating virtual file %s", path);
|
||||
dev = VFile::createFile(path, mode);
|
||||
}
|
||||
if (dev) {
|
||||
@@ -136,7 +136,7 @@ int px4_close(int fd)
|
||||
int ret;
|
||||
if (valid_fd(fd)) {
|
||||
VDev *dev = (VDev *)(filemap[fd]->vdev);
|
||||
PX4_DEBUG("px4_close fd = %d\n", fd);
|
||||
PX4_DEBUG("px4_close fd = %d", fd);
|
||||
ret = dev->close(filemap[fd]);
|
||||
filemap[fd] = NULL;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ ssize_t px4_read(int fd, void *buffer, size_t buflen)
|
||||
int ret;
|
||||
if (valid_fd(fd)) {
|
||||
VDev *dev = (VDev *)(filemap[fd]->vdev);
|
||||
PX4_DEBUG("px4_read fd = %d\n", fd);
|
||||
PX4_DEBUG("px4_read fd = %d", fd);
|
||||
ret = dev->read(filemap[fd], (char *)buffer, buflen);
|
||||
}
|
||||
else {
|
||||
@@ -173,7 +173,7 @@ ssize_t px4_write(int fd, const void *buffer, size_t buflen)
|
||||
int ret;
|
||||
if (valid_fd(fd)) {
|
||||
VDev *dev = (VDev *)(filemap[fd]->vdev);
|
||||
PX4_DEBUG("px4_write fd = %d\n", fd);
|
||||
PX4_DEBUG("px4_write fd = %d", fd);
|
||||
ret = dev->write(filemap[fd], (const char *)buffer, buflen);
|
||||
}
|
||||
else {
|
||||
@@ -188,7 +188,7 @@ ssize_t px4_write(int fd, const void *buffer, size_t buflen)
|
||||
|
||||
int px4_ioctl(int fd, int cmd, unsigned long arg)
|
||||
{
|
||||
PX4_DEBUG("px4_ioctl fd = %d\n", fd);
|
||||
PX4_DEBUG("px4_ioctl fd = %d", fd);
|
||||
int ret = 0;
|
||||
if (valid_fd(fd)) {
|
||||
VDev *dev = (VDev *)(filemap[fd]->vdev);
|
||||
@@ -212,7 +212,7 @@ int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
||||
unsigned int i;
|
||||
struct timespec ts;
|
||||
|
||||
PX4_DEBUG("Called px4_poll timeout = %d\n", timeout);
|
||||
PX4_DEBUG("Called px4_poll timeout = %d", timeout);
|
||||
sem_init(&sem, 0, 0);
|
||||
|
||||
// For each fd
|
||||
@@ -226,7 +226,7 @@ int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
||||
if (valid_fd(fds[i].fd))
|
||||
{
|
||||
VDev *dev = (VDev *)(filemap[fds[i].fd]->vdev);;
|
||||
PX4_DEBUG("px4_poll: VDev->poll(setup) %d\n", fds[i].fd);
|
||||
PX4_DEBUG("px4_poll: VDev->poll(setup) %d", fds[i].fd);
|
||||
ret = dev->poll(filemap[fds[i].fd], &fds[i], true);
|
||||
|
||||
if (ret < 0)
|
||||
@@ -270,7 +270,7 @@ int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
||||
if (valid_fd(fds[i].fd))
|
||||
{
|
||||
VDev *dev = (VDev *)(filemap[fds[i].fd]->vdev);;
|
||||
PX4_DEBUG("px4_poll: VDev->poll(teardown) %d\n", fds[i].fd);
|
||||
PX4_DEBUG("px4_poll: VDev->poll(teardown) %d", fds[i].fd);
|
||||
ret = dev->poll(filemap[fds[i].fd], &fds[i], false);
|
||||
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user