Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn Webb
liblattutil
Commits
384c7855
Commit
384c7855
authored
Jul 18, 2021
by
Shawn Webb
Browse files
Add debug log callback
Signed-off-by:
Shawn Webb
<
shawn.webb@hardenedbsd.org
>
parent
4a87ae63
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/liblattutil.h
View file @
384c7855
...
...
@@ -61,6 +61,7 @@ typedef struct _lllog {
int
ll_verbosity
;
char
*
ll_path
;
log_cb
ll_log_debug
;
log_cb
ll_log_err
;
log_cb
ll_log_info
;
log_cb
ll_log_warn
;
...
...
@@ -330,6 +331,8 @@ const ucl_object_t *lattutil_sqlite_get_row(lattutil_sqlite_query_t *, size_t);
const
ucl_object_t
*
lattutil_sqlite_get_column
(
const
ucl_object_t
*
,
size_t
);
#ifdef _lattutil_internal
ssize_t
lattutil_log_syslog_debug
(
lattutil_log_t
*
,
int
,
const
char
*
,
...);
ssize_t
lattutil_log_syslog_err
(
lattutil_log_t
*
,
int
,
const
char
*
,
...);
ssize_t
lattutil_log_syslog_info
(
lattutil_log_t
*
,
int
,
...
...
@@ -338,6 +341,8 @@ ssize_t lattutil_log_syslog_warn(lattutil_log_t *, int,
const
char
*
,
...);
void
lattutil_log_syslog_close
(
lattutil_log_t
*
);
ssize_t
lattutil_log_dummy_debug
(
lattutil_log_t
*
,
int
,
const
char
*
,
...);
ssize_t
lattutil_log_dummy_err
(
lattutil_log_t
*
,
int
,
const
char
*
,
...);
ssize_t
lattutil_log_dummy_info
(
lattutil_log_t
*
,
int
,
...
...
src/log-dummy.c
View file @
384c7855
...
...
@@ -35,11 +35,20 @@ lattutil_log_dummy_init(lattutil_log_t *res)
{
res
->
ll_log_close
=
lattutil_log_dummy_close
;
res
->
ll_log_debug
=
lattutil_log_dummy_debug
;
res
->
ll_log_err
=
lattutil_log_dummy_err
;
res
->
ll_log_info
=
lattutil_log_dummy_info
;
res
->
ll_log_warn
=
lattutil_log_dummy_warn
;
}
ssize_t
lattutil_log_dummy_debug
(
lattutil_log_t
*
logp
,
int
verbose
,
const
char
*
fmt
,
...)
{
return
(
0
);
}
ssize_t
lattutil_log_dummy_err
(
lattutil_log_t
*
logp
,
int
verbose
,
const
char
*
fmt
,
...)
...
...
src/log-main.c
View file @
384c7855
...
...
@@ -87,7 +87,8 @@ lattutil_log_ready(lattutil_log_t *logp)
return
(
false
);
}
if
(
logp
->
ll_log_err
==
NULL
||
if
(
logp
->
ll_log_debug
==
NULL
||
logp
->
ll_log_err
==
NULL
||
logp
->
ll_log_info
==
NULL
||
logp
->
ll_log_warn
==
NULL
)
{
return
(
false
);
...
...
src/log-syslog.c
View file @
384c7855
...
...
@@ -38,6 +38,7 @@ lattutil_log_syslog_init(lattutil_log_t *logp, int logopt, int facility)
const
char
*
name
;
logp
->
ll_log_close
=
lattutil_log_syslog_close
;
logp
->
ll_log_debug
=
lattutil_log_syslog_debug
;
logp
->
ll_log_err
=
lattutil_log_syslog_err
;
logp
->
ll_log_info
=
lattutil_log_syslog_info
;
logp
->
ll_log_warn
=
lattutil_log_syslog_warn
;
...
...
@@ -55,6 +56,31 @@ lattutil_log_syslog_init(lattutil_log_t *logp, int logopt, int facility)
return
(
true
);
}
ssize_t
lattutil_log_syslog_debug
(
lattutil_log_t
*
logp
,
int
verbose
,
const
char
*
fmt
,
...)
{
va_list
args
;
size_t
len
;
char
*
msg
;
va_start
(
args
,
fmt
);
if
(
verbose
==
-
1
||
verbose
>=
logp
->
ll_verbosity
)
{
msg
=
NULL
;
vasprintf
(
&
msg
,
fmt
,
args
);
if
(
msg
==
NULL
)
{
len
=
-
1
;
goto
end
;
}
len
=
strlen
(
msg
);
syslog
(
LOG_DEBUG
,
"DEBUG: %s"
,
msg
);
}
va_end
(
args
);
end:
return
(
len
);
}
ssize_t
lattutil_log_syslog_err
(
lattutil_log_t
*
logp
,
int
verbose
,
const
char
*
fmt
,
...)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment