Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
855358c8
Unverified
Commit
855358c8
authored
Sep 11, 2018
by
Christian Brauner
Committed by
GitHub
Sep 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2601 from 2xsec/bugfix
log: support dlog
parents
88fbc010
5c7bfc02
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
0 deletions
+79
-0
configure.ac
configure.ac
+16
-0
Makefile.am
src/lxc/Makefile.am
+4
-0
log.c
src/lxc/log.c
+59
-0
No files found.
configure.ac
View file @
855358c8
...
@@ -693,6 +693,19 @@ AC_ARG_ENABLE([thread-safety],
...
@@ -693,6 +693,19 @@ AC_ARG_ENABLE([thread-safety],
[], [enable_thread_safety=yes])
[], [enable_thread_safety=yes])
AM_CONDITIONAL([ENFORCE_THREAD_SAFETY], [test "x$enable_thread_safety" = "xyes"])
AM_CONDITIONAL([ENFORCE_THREAD_SAFETY], [test "x$enable_thread_safety" = "xyes"])
AC_ARG_ENABLE([dlog],
[AC_HELP_STRING([--enable-dlog], [enable dlog support [default=no]])],
[], [enable_dlog=no])
AM_CONDITIONAL([ENABLE_DLOG], [test "x$enable_dlog" = "xyes"])
AM_COND_IF([ENABLE_DLOG],
[PKG_CHECK_MODULES([DLOG],[dlog],[],[
AC_CHECK_HEADER([dlog.h],[],[AC_MSG_ERROR([You must install the dlog development package in order to compile lxc])])
AC_CHECK_LIB([dlog], [dlog_print],[],[AC_MSG_ERROR([You must install the dlog development package in order to compile lxc])])
AC_SUBST([DLOG_LIBS], [-ldlog])
])
])
# Files requiring some variable expansion
# Files requiring some variable expansion
AC_CONFIG_FILES([
AC_CONFIG_FILES([
Makefile
Makefile
...
@@ -939,4 +952,7 @@ Paths:
...
@@ -939,4 +952,7 @@ Paths:
Thread-safety:
Thread-safety:
- enforce: $enable_thread_safety
- enforce: $enable_thread_safety
Dlog:
- enable: $enable_dlog
EOF
EOF
src/lxc/Makefile.am
View file @
855358c8
...
@@ -211,6 +211,10 @@ if ENABLE_SELINUX
...
@@ -211,6 +211,10 @@ if ENABLE_SELINUX
AM_CFLAGS
+=
-DHAVE_SELINUX
AM_CFLAGS
+=
-DHAVE_SELINUX
endif
endif
if
ENABLE_DLOG
AM_CFLAGS
+=
-DHAVE_DLOG
endif
if
USE_CONFIGPATH_LOGS
if
USE_CONFIGPATH_LOGS
AM_CFLAGS
+=
-DUSE_CONFIGPATH_LOGS
AM_CFLAGS
+=
-DUSE_CONFIGPATH_LOGS
endif
endif
...
...
src/lxc/log.c
View file @
855358c8
...
@@ -49,6 +49,13 @@
...
@@ -49,6 +49,13 @@
#include "include/strlcpy.h"
#include "include/strlcpy.h"
#endif
#endif
#if HAVE_DLOG
#include <dlog.h>
#undef LOG_TAG
#define LOG_TAG "LXC"
#endif
/* We're logging in seconds and nanoseconds. Assuming that the underlying
/* We're logging in seconds and nanoseconds. Assuming that the underlying
* datatype is currently at maximum a 64bit integer, we have a date string that
* datatype is currently at maximum a 64bit integer, we have a date string that
* is of maximum length (2^64 - 1) * 2 = (21 + 21) = 42.
* is of maximum length (2^64 - 1) * 2 = (21 + 21) = 42.
...
@@ -347,6 +354,41 @@ again:
...
@@ -347,6 +354,41 @@ again:
return
ret
;
return
ret
;
}
}
#if HAVE_DLOG
static
int
log_append_dlog
(
const
struct
lxc_log_appender
*
appender
,
struct
lxc_log_event
*
event
)
{
if
(
event
->
priority
<
LXC_LOG_LEVEL_ERROR
)
return
0
;
switch
(
event
->
priority
)
{
case
LXC_LOG_LEVEL_TRACE
:
case
LXC_LOG_LEVEL_DEBUG
:
LOG_VA
(
LOG_DEBUG
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
break
;
case
LXC_LOG_LEVEL_INFO
:
LOG_VA
(
LOG_INFO
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
break
;
case
LXC_LOG_LEVEL_NOTICE
:
case
LXC_LOG_LEVEL_WARN
:
LOG_VA
(
LOG_WARN
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
break
;
case
LXC_LOG_LEVEL_ERROR
:
LOG_VA
(
LOG_ERROR
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
break
;
case
LXC_LOG_LEVEL_CRIT
:
case
LXC_LOG_LEVEL_ALERT
:
case
LXC_LOG_LEVEL_FATAL
:
LOG_VA
(
LOG_FATAL
,
LOG_TAG
,
event
->
fmt
,
*
event
->
vap
);
break
;
default:
break
;
}
return
0
;
}
#endif
static
struct
lxc_log_appender
log_appender_syslog
=
{
static
struct
lxc_log_appender
log_appender_syslog
=
{
.
name
=
"syslog"
,
.
name
=
"syslog"
,
.
append
=
log_append_syslog
,
.
append
=
log_append_syslog
,
...
@@ -365,6 +407,14 @@ static struct lxc_log_appender log_appender_logfile = {
...
@@ -365,6 +407,14 @@ static struct lxc_log_appender log_appender_logfile = {
.
next
=
NULL
,
.
next
=
NULL
,
};
};
#if HAVE_DLOG
static
struct
lxc_log_appender
log_appender_dlog
=
{
.
name
=
"dlog"
,
.
append
=
log_append_dlog
,
.
next
=
NULL
,
};
#endif
static
struct
lxc_log_category
log_root
=
{
static
struct
lxc_log_category
log_root
=
{
.
name
=
"root"
,
.
name
=
"root"
,
.
priority
=
LXC_LOG_LEVEL_ERROR
,
.
priority
=
LXC_LOG_LEVEL_ERROR
,
...
@@ -372,12 +422,21 @@ static struct lxc_log_category log_root = {
...
@@ -372,12 +422,21 @@ static struct lxc_log_category log_root = {
.
parent
=
NULL
,
.
parent
=
NULL
,
};
};
#if HAVE_DLOG
struct
lxc_log_category
lxc_log_category_lxc
=
{
.
name
=
"lxc"
,
.
priority
=
LXC_LOG_LEVEL_ERROR
,
.
appender
=
&
log_appender_dlog
,
.
parent
=
&
log_root
};
#else
struct
lxc_log_category
lxc_log_category_lxc
=
{
struct
lxc_log_category
lxc_log_category_lxc
=
{
.
name
=
"lxc"
,
.
name
=
"lxc"
,
.
priority
=
LXC_LOG_LEVEL_ERROR
,
.
priority
=
LXC_LOG_LEVEL_ERROR
,
.
appender
=
&
log_appender_logfile
,
.
appender
=
&
log_appender_logfile
,
.
parent
=
&
log_root
.
parent
=
&
log_root
};
};
#endif
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static
int
build_dir
(
const
char
*
name
)
static
int
build_dir
(
const
char
*
name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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