Skip to content

Commit c98ca0f

Browse files
Libwebsockets log functions (#12)
1 parent 150b91d commit c98ca0f

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name = "Libwebsockets"
22
uuid = "30a1cee6-c274-443c-b274-d8ea34e8f87d"
3-
version = "1.0.4"
3+
version = "1.0.5"
44

55
[deps]
66
libwebsockets_jll = "b6b84edf-6aef-5ff6-9b66-656961a84a09"
7+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
78

89
[compat]
9-
julia = "1.8"
10+
julia = "1.8"

src/Libwebsockets.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module Libwebsockets
22

33
using libwebsockets_jll
4+
using Printf
45

56
include("consts.jl")
67
include("types.jl")
78
include("functions.jl")
9+
include("external.jl")
810

911
end

src/external.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Printf
2+
3+
export lwsl_notice,
4+
lwsl_warn,
5+
lwsl_info,
6+
lwsl_debug,
7+
lwsl_parser,
8+
lwsl_header,
9+
lwsl_ext,
10+
lwsl_client,
11+
lwsl_latency,
12+
lwsl_thread,
13+
lwsl_user
14+
15+
function _log(filter::Int, format::AbstractString, args...)
16+
log_str = Printf.format(Printf.Format(format), args...)
17+
return _lws_log(filter, log_str)
18+
end
19+
20+
lwsl_notice(args...) = _log(LLL_ERR, args...)
21+
lwsl_warn(args...) = _log(LLL_NOTICE, args...)
22+
lwsl_info(args...) = _log(LLL_INFO, args...)
23+
lwsl_debug(args...) = _log(LLL_DEBUG, args...)
24+
lwsl_parser(args...) = _log(LLL_PARSER, args...)
25+
lwsl_header(args...) = _log(LLL_HEADER, args...)
26+
lwsl_ext(args...) = _log(LLL_EXT, args...)
27+
lwsl_client(args...) = _log(LLL_CLIENT, args...)
28+
lwsl_latency(args...) = _log(LLL_LATENCY, args...)
29+
lwsl_thread(args...) = _log(LLL_THREAD, args...)
30+
lwsl_user(args...) = _log(LLL_USER, args...)

src/functions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ function lws_log_prepend_wsi(cx, obj, p, e)
184184
ccall((:lws_log_prepend_wsi, libwebsockets), Cvoid, (Ptr{LwsLogCx}, Ptr{Cvoid}, Ptr{Ptr{Cchar}}, Ptr{Cchar}), cx, obj, p, e)
185185
end
186186

187+
function _lws_log(filter, format, args...)
188+
ccall((:_lws_log, libwebsockets), Cvoid, (Cint, Ptr{Cchar}, Any...), filter, format, args)
189+
end
190+
187191
function lwsl_hexdump_level_cx(cx, prep, obj, hexdump_level, vbuf, len)
188192
ccall((:lwsl_hexdump_level_cx, libwebsockets), Cvoid, (Ptr{LwsLogCx}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Ptr{Cvoid}, Csize_t), cx, prep, obj, hexdump_level, vbuf, len)
189193
end

0 commit comments

Comments
 (0)