Skip to content

Commit

Permalink
export log api
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
  • Loading branch information
Jianhui Zhao committed Jun 14, 2018
1 parent a1c1d55 commit e5353d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions example/helloworld.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libubox/ulog.h>

struct uwsc_client *gcl;
struct uloop_fd fd;
Expand All @@ -44,7 +43,7 @@ void fd_handler(struct uloop_fd *u, unsigned int events)

static void uwsc_onopen(struct uwsc_client *cl)
{
ULOG_INFO("onopen\n");
uwsc_log_info("onopen\n");

fd.fd = STDIN_FILENO;
fd.cb = fd_handler;
Expand Down Expand Up @@ -72,12 +71,12 @@ static void uwsc_onmessage(struct uwsc_client *cl, void *data, uint64_t len, enu

static void uwsc_onerror(struct uwsc_client *cl)
{
ULOG_INFO("onerror:%d\n", cl->error);
uwsc_log_info("onerror:%d\n", cl->error);
}

static void uwsc_onclose(struct uwsc_client *cl)
{
ULOG_INFO("onclose\n");
uwsc_log_info("onclose\n");
uloop_end();
}

Expand Down Expand Up @@ -121,7 +120,7 @@ int main(int argc, char **argv)
}

if (!verbose)
ulog_threshold(LOG_ERR);
uwsc_log_threshold(LOG_ERR);

uloop_init();

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/config.h
${CMAKE_CURRENT_SOURCE_DIR}/log.h
${CMAKE_CURRENT_SOURCE_DIR}/uwsc.h
DESTINATION
include/uwsc
Expand Down
4 changes: 4 additions & 0 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
#ifndef _LOG_H
#define _LOG_H

#include <string.h>

#include <libubox/ulog.h>

#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

#define uwsc_log_threshold(priority) ulog_threshold(priority)

/*
* Use the syslog output log and include the name and number of rows at the call
*/
Expand Down
1 change: 1 addition & 0 deletions src/uwsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <libubox/uloop.h>
#include <libubox/ustream.h>

#include "log.h"
#include "config.h"

#if (UWSC_SSL_SUPPORT)
Expand Down

0 comments on commit e5353d7

Please sign in to comment.