mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-15 13:47:41 +00:00
API: expose function lxc_log_init
Signed-off-by: 0x0916 <w@laoqinren.net>
This commit is contained in:
parent
beda39ebbd
commit
73b910a341
@ -44,6 +44,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "caps.h"
|
#include "caps.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "lxccontainer.h"
|
||||||
|
|
||||||
/* 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
|
||||||
@ -543,9 +544,7 @@ extern void lxc_log_enable_syslog(void)
|
|||||||
* Called from lxc front-end programs (like lxc-create, lxc-start) to
|
* Called from lxc front-end programs (like lxc-create, lxc-start) to
|
||||||
* initalize the log defaults.
|
* initalize the log defaults.
|
||||||
*/
|
*/
|
||||||
extern int lxc_log_init(const char *name, const char *file,
|
extern int lxc_log_init(struct lxc_log *log)
|
||||||
const char *priority, const char *prefix, int quiet,
|
|
||||||
const char *lxcpath)
|
|
||||||
{
|
{
|
||||||
int lxc_priority = LXC_LOG_PRIORITY_ERROR;
|
int lxc_priority = LXC_LOG_PRIORITY_ERROR;
|
||||||
int ret;
|
int ret;
|
||||||
@ -555,8 +554,8 @@ extern int lxc_log_init(const char *name, const char *file,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priority)
|
if (log->priority)
|
||||||
lxc_priority = lxc_log_priority_to_int(priority);
|
lxc_priority = lxc_log_priority_to_int(log->priority);
|
||||||
|
|
||||||
if (!lxc_loglevel_specified) {
|
if (!lxc_loglevel_specified) {
|
||||||
lxc_log_category_lxc.priority = lxc_priority;
|
lxc_log_category_lxc.priority = lxc_priority;
|
||||||
@ -564,49 +563,49 @@ extern int lxc_log_init(const char *name, const char *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!lxc_quiet_specified) {
|
if (!lxc_quiet_specified) {
|
||||||
if (!quiet)
|
if (!log->quiet)
|
||||||
lxc_log_category_lxc.appender->next = &log_appender_stderr;
|
lxc_log_category_lxc.appender->next = &log_appender_stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefix)
|
if (log->prefix)
|
||||||
lxc_log_set_prefix(prefix);
|
lxc_log_set_prefix(log->prefix);
|
||||||
|
|
||||||
if (name)
|
if (log->name)
|
||||||
log_vmname = strdup(name);
|
log_vmname = strdup(log->name);
|
||||||
|
|
||||||
if (file) {
|
if (log->file) {
|
||||||
if (strcmp(file, "none") == 0)
|
if (strcmp(log->file, "none") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
ret = __lxc_log_set_file(file, 1);
|
ret = __lxc_log_set_file(log->file, 1);
|
||||||
lxc_log_use_global_fd = 1;
|
lxc_log_use_global_fd = 1;
|
||||||
} else {
|
} else {
|
||||||
/* if no name was specified, there nothing to do */
|
/* if no name was specified, there nothing to do */
|
||||||
if (!name)
|
if (!log->name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
if (!lxcpath)
|
if (!log->lxcpath)
|
||||||
lxcpath = LOGPATH;
|
log->lxcpath = LOGPATH;
|
||||||
|
|
||||||
/* try LOGPATH if lxcpath is the default for the privileged containers */
|
/* try LOGPATH if lxcpath is the default for the privileged containers */
|
||||||
if (!geteuid() && strcmp(LXCPATH, lxcpath) == 0)
|
if (!geteuid() && strcmp(LXCPATH, log->lxcpath) == 0)
|
||||||
ret = _lxc_log_set_file(name, NULL, 0);
|
ret = _lxc_log_set_file(log->name, NULL, 0);
|
||||||
|
|
||||||
/* try in lxcpath */
|
/* try in lxcpath */
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = _lxc_log_set_file(name, lxcpath, 1);
|
ret = _lxc_log_set_file(log->name, log->lxcpath, 1);
|
||||||
|
|
||||||
/* try LOGPATH in case its writable by the caller */
|
/* try LOGPATH in case its writable by the caller */
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
ret = _lxc_log_set_file(name, NULL, 0);
|
ret = _lxc_log_set_file(log->name, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If !file, that is, if the user did not request this logpath, then
|
* If !file, that is, if the user did not request this logpath, then
|
||||||
* ignore failures and continue logging to console
|
* ignore failures and continue logging to console
|
||||||
*/
|
*/
|
||||||
if (!file && ret != 0) {
|
if (!log->file && ret != 0) {
|
||||||
INFO("Ignoring failure to open default logfile.");
|
INFO("Ignoring failure to open default logfile.");
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
@ -348,10 +348,6 @@ ATTR_UNUSED static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo, \
|
|||||||
|
|
||||||
extern int lxc_log_fd;
|
extern int lxc_log_fd;
|
||||||
|
|
||||||
extern int lxc_log_init(const char *name, const char *file,
|
|
||||||
const char *priority, const char *prefix, int quiet,
|
|
||||||
const char *lxcpath);
|
|
||||||
|
|
||||||
extern int lxc_log_set_file(int *fd, const char *fname);
|
extern int lxc_log_set_file(int *fd, const char *fname);
|
||||||
extern int lxc_log_syslog(int facility);
|
extern int lxc_log_syslog(int facility);
|
||||||
extern void lxc_log_enable_syslog(void);
|
extern void lxc_log_enable_syslog(void);
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "mainloop.h"
|
#include "mainloop.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "lxccontainer.h"
|
||||||
|
|
||||||
#define CLIENTFDS_CHUNK 64
|
#define CLIENTFDS_CHUNK 64
|
||||||
|
|
||||||
@ -350,6 +351,7 @@ int main(int argc, char *argv[])
|
|||||||
char *lxcpath = argv[1];
|
char *lxcpath = argv[1];
|
||||||
bool mainloop_opened = false;
|
bool mainloop_opened = false;
|
||||||
bool monitord_created = false;
|
bool monitord_created = false;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -364,7 +366,13 @@ int main(int argc, char *argv[])
|
|||||||
if (ret < 0 || ret >= sizeof(logpath))
|
if (ret < 0 || ret >= sizeof(logpath))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
ret = lxc_log_init(NULL, logpath, "DEBUG", "lxc-monitord", 0, lxcpath);
|
log.name = NULL;
|
||||||
|
log.file = logpath;
|
||||||
|
log.priority = "DEBUG";
|
||||||
|
log.prefix = "lxc-monitord";
|
||||||
|
log.quiet = 0;
|
||||||
|
log.lxcpath = lxcpath;
|
||||||
|
ret = lxc_log_init(&log);
|
||||||
if (ret)
|
if (ret)
|
||||||
INFO("Failed to open log file %s, log will be lost.", lxcpath);
|
INFO("Failed to open log file %s, log will be lost.", lxcpath);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
@ -1017,6 +1017,22 @@ int list_active_containers(const char *lxcpath, char ***names, struct lxc_contai
|
|||||||
*/
|
*/
|
||||||
int list_all_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
|
int list_all_containers(const char *lxcpath, char ***names, struct lxc_container ***cret);
|
||||||
|
|
||||||
|
struct lxc_log {
|
||||||
|
const char *name;
|
||||||
|
const char *lxcpath;
|
||||||
|
const char *file;
|
||||||
|
const char *priority;
|
||||||
|
const char *prefix;
|
||||||
|
bool quiet;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*\brief Initialize the log
|
||||||
|
*
|
||||||
|
*\param log lxc log configuration.
|
||||||
|
*/
|
||||||
|
int lxc_log_init(struct lxc_log *log);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Close log file.
|
* \brief Close log file.
|
||||||
*/
|
*/
|
||||||
|
@ -371,6 +371,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int ret = -1, r;
|
int ret = -1, r;
|
||||||
int wexit = 0;
|
int wexit = 0;
|
||||||
|
struct lxc_log log;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
lxc_attach_options_t attach_options = LXC_ATTACH_OPTIONS_DEFAULT;
|
lxc_attach_options_t attach_options = LXC_ATTACH_OPTIONS_DEFAULT;
|
||||||
lxc_attach_command_t command = (lxc_attach_command_t){.program = NULL};
|
lxc_attach_command_t command = (lxc_attach_command_t){.program = NULL};
|
||||||
@ -386,8 +387,13 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
r = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]);
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
r = lxc_log_init(&log);
|
||||||
if (r)
|
if (r)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
@ -352,12 +352,19 @@ int main(int argc, char *argv[])
|
|||||||
struct lxc_container **containers = NULL;
|
struct lxc_container **containers = NULL;
|
||||||
struct lxc_list **c_groups_lists = NULL;
|
struct lxc_list **c_groups_lists = NULL;
|
||||||
struct lxc_list *cmd_group;
|
struct lxc_list *cmd_group;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char *state_object = NULL, *value = NULL;
|
char *state_object = NULL, *value = NULL;
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -74,8 +75,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ static bool restore(struct lxc_container *c)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
@ -242,8 +243,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
@ -98,6 +98,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
ret = lxc_arguments_parse(&my_args, argc, argv);
|
ret = lxc_arguments_parse(&my_args, argc, argv);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -106,8 +107,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
ret = lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]);
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
ret = lxc_log_init(&log);
|
||||||
if (ret)
|
if (ret)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
@ -169,6 +169,7 @@ static int parse_ovl_mnt(char *mntstring, enum mnttype type);
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
@ -178,8 +179,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(ret);
|
exit(ret);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -208,6 +208,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
struct bdev_specs spec;
|
struct bdev_specs spec;
|
||||||
|
struct lxc_log log;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
@ -216,8 +217,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c);
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
bool bret;
|
bool bret;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
@ -75,8 +76,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
if (my_args.quiet)
|
if (my_args.quiet)
|
||||||
|
@ -101,6 +101,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
char *cmd, *dev_name, *dst_name;
|
char *cmd, *dev_name, *dst_name;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@ -115,8 +116,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
goto err;
|
goto err;
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "start.h"
|
#include "start.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "lxccontainer.h"
|
||||||
|
|
||||||
lxc_log_define(lxc_execute_ui, lxc);
|
lxc_log_define(lxc_execute_ui, lxc);
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char *rcfile;
|
char *rcfile;
|
||||||
struct lxc_conf *conf;
|
struct lxc_conf *conf;
|
||||||
|
struct lxc_log log;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lxc_list_init(&defines);
|
lxc_list_init(&defines);
|
||||||
@ -116,8 +118,14 @@ int main(int argc, char *argv[])
|
|||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ Options :\n\
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -64,8 +65,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ static int print_info(const char *name, const char *lxcpath)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(ret);
|
exit(ret);
|
||||||
@ -401,8 +402,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(ret);
|
exit(ret);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "caps.h"
|
#include "caps.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "initutils.h"
|
#include "initutils.h"
|
||||||
|
#include "lxccontainer.h"
|
||||||
|
|
||||||
lxc_log_define(lxc_init, lxc);
|
lxc_log_define(lxc_init, lxc);
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ int main(int argc, char *argv[])
|
|||||||
int i, have_status = 0, shutdown = 0;
|
int i, have_status = 0, shutdown = 0;
|
||||||
int opt;
|
int opt;
|
||||||
char *lxcpath = NULL, *name = NULL, *logpriority = NULL;
|
char *lxcpath = NULL, *name = NULL, *logpriority = NULL;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "n:l:qP:", options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "n:l:qP:", options, NULL)) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@ -104,8 +106,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = lxc_log_init(name, name ? NULL : "none", logpriority,
|
log.name = name;
|
||||||
basename(argv[0]), quiet, lxcpath);
|
log.file = name ? NULL : "none";
|
||||||
|
log.priority = logpriority;
|
||||||
|
log.prefix = basename(argv[0]);
|
||||||
|
log.quiet = quiet;
|
||||||
|
log.lxcpath = lxcpath;
|
||||||
|
|
||||||
|
err = lxc_log_init(&log);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
@ -203,6 +203,7 @@ Options :\n\
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
struct lxc_log log;
|
||||||
/*
|
/*
|
||||||
* The lxc parser requires that my_args.name is set. So let's satisfy
|
* The lxc parser requires that my_args.name is set. So let's satisfy
|
||||||
* that condition by setting a dummy name which is never used.
|
* that condition by setting a dummy name which is never used.
|
||||||
@ -218,8 +219,14 @@ int main(int argc, char *argv[])
|
|||||||
* We set the first argument that usually takes my_args.name to NULL so
|
* We set the first argument that usually takes my_args.name to NULL so
|
||||||
* that the log is only used when the user specifies a file.
|
* that the log is only used when the user specifies a file.
|
||||||
*/
|
*/
|
||||||
if (lxc_log_init(NULL, my_args.log_file, my_args.log_priority,
|
log.name = NULL;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "arguments.h"
|
#include "arguments.h"
|
||||||
|
#include "lxccontainer.h"
|
||||||
|
|
||||||
lxc_log_define(lxc_monitor_ui, lxc);
|
lxc_log_define(lxc_monitor_ui, lxc);
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ int main(int argc, char *argv[])
|
|||||||
struct pollfd *fds;
|
struct pollfd *fds;
|
||||||
nfds_t nfds;
|
nfds_t nfds;
|
||||||
int len, rc_main, rc_snp, i;
|
int len, rc_main, rc_snp, i;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
rc_main = EXIT_FAILURE;
|
rc_main = EXIT_FAILURE;
|
||||||
|
|
||||||
@ -100,8 +102,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(rc_main);
|
exit(rc_main);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ static void print_file(char *path);
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
@ -89,8 +90,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int err = EXIT_FAILURE;
|
int err = EXIT_FAILURE;
|
||||||
struct lxc_conf *conf;
|
struct lxc_conf *conf;
|
||||||
|
struct lxc_log log;
|
||||||
char *const *args;
|
char *const *args;
|
||||||
char *rcfile = NULL;
|
char *rcfile = NULL;
|
||||||
char *const default_args[] = {
|
char *const default_args[] = {
|
||||||
@ -226,8 +227,14 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
args = my_args.argv;
|
args = my_args.argv;
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(err);
|
exit(err);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -155,14 +155,21 @@ out:
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
bool s;
|
bool s;
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(ret);
|
exit(ret);
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(ret);
|
exit(ret);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ Options :\n\
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -62,8 +63,15 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ Options :\n\
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct lxc_container *c;
|
struct lxc_container *c;
|
||||||
|
struct lxc_log log;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -90,8 +91,14 @@ int main(int argc, char *argv[])
|
|||||||
if (!my_args.log_file)
|
if (!my_args.log_file)
|
||||||
my_args.log_file = "none";
|
my_args.log_file = "none";
|
||||||
|
|
||||||
if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority,
|
log.name = my_args.name;
|
||||||
my_args.progname, my_args.quiet, my_args.lxcpath[0]))
|
log.file = my_args.log_file;
|
||||||
|
log.priority = my_args.log_priority;
|
||||||
|
log.prefix = my_args.progname;
|
||||||
|
log.quiet = my_args.quiet;
|
||||||
|
log.lxcpath = my_args.lxcpath[0];
|
||||||
|
|
||||||
|
if (lxc_log_init(&log))
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
lxc_log_options_no_override();
|
lxc_log_options_no_override();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user