Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/log/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ add_executable(log-modules modules.c)
target_link_libraries(log-modules bfdev)
add_test(log-modules log-modules)

add_executable(log-syslog syslog.c)
target_link_libraries(log-syslog bfdev)
add_test(log-syslog log-syslog)

if(${CMAKE_PROJECT_NAME} STREQUAL "bfdev")
install(FILES
simple.c
modules.c
syslog.c
DESTINATION
${CMAKE_INSTALL_DOCDIR}/examples/log
)

install(TARGETS
log-simple
log-modules
log-syslog
DESTINATION
${CMAKE_INSTALL_DOCDIR}/bin
)
Expand Down
20 changes: 20 additions & 0 deletions examples/log/syslog.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright(c) 2025 Zhenlin Wang <sanpeqf@gmail.com>
*/

#define MODULE_NAME "log-syslog"
#define bfdev_log_fmt(fmt) MODULE_NAME ": " fmt

#include <bfdev/modules/log.h>
#include <syslog.h>

int
main(int argc, const char *argv[])
{
openlog(MODULE_NAME, LOG_PID | LOG_CONS, LOG_DAEMON);
bfdev_log_default.write = bfdev_log_write_syslog;
bfdev_log("helloworld\n");

return 0;
}
2 changes: 1 addition & 1 deletion include/bfdev/modules/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern int
bfdev_log_chain_pid(bfdev_log_message_t *msg, void *pdata);

extern int
bfdev_log_write_syslog(bfdev_log_message_t *msg, void *pdata);
bfdev_log_write_syslog(bfdev_log_message_t *msg);

BFDEV_END_DECLS

Expand Down
2 changes: 1 addition & 1 deletion modules/log/write-syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ syslog_level[] = {
};

export int
bfdev_log_write_syslog(bfdev_log_message_t *msg, void *pdata)
bfdev_log_write_syslog(bfdev_log_message_t *msg)
{
int level, priority;

Expand Down
Loading