Quoting Dwight Engen ([email protected]):
> +/*
> + * Build the path to the log file
> + * @name : the name of the container
> + * @lxcpath : the lxcpath to use as a basename or NULL to use LOGPATH
> + * Returns malloced path on sucess, or NULL on failure
> + */
> +static char *build_log_path(const char *name, const char *lxcpath)
> {
> char *p;
> int len, ret;
>
> /*
> - * '$logpath' + '/' + '$name' + '.log' + '\0'
> - * or
> + * If USE_CONFIGPATH_LOGS is true the resulting path will be:
> * '$logpath' + '/' + '$name' + '/' + '$name' + '.log' + '\0'
> - * sizeof(LOGPATH) includes its \0
> + *
> + * If USE_CONFIGPATH_LOGS is false the resulting path will be:
> + * '$logpath' + '/' + '$name' + '.log' + '\0'
> */
> - len = sizeof(LOGPATH) + strlen(name) + 6;
> + len = strlen(name) + 6; /* 6 == '/' + '.log' + '\0' */
> + if (!lxcpath)
> + lxcpath = LOGPATH;
> #if USE_CONFIGPATH_LOGS
> - len += strlen(name) + 1; /* add "/$container_name/" */
> + len += strlen(lxcpath) + 1 + strlen(name) + 1; /* add
> "/$container_name/" */
> +#else
> + len += strlen(lxcpath) + 1;
> #endif
> p = malloc(len);
> if (!p)
> return p;
> #if USE_CONFIGPATH_LOGS
> - ret = snprintf(p, len, "%s/%s/%s.log", LOGPATH, name, name);
> + ret = snprintf(p, len, "%s/%s/%s.log", lxcpath, name, name);
> #else
> - ret = snprintf(p, len, "%s/%s.log", LOGPATH, name);
> + ret = snprintf(p, len, "%s/%s.log", lxcpath, name);
Hi Dwight,
I've pushed this patch to staging, but I do notice an oddity when
USE_CONFIGPATH_LOGS=n (as on ubuntu). When I now start a container
with an lxcpath, i.e. lxc-start -n c1 -P /home/serge/lxcbase,
then the logfile is at /home/serge/lxcbase/dir1.log, not
/home/serge/lxcbase/dir1/dir1.log. I think it would be better to have
something like
#if USE_CONFIGPATH_LOGS
ret = snprintf(p, len, "%s/%s/%s.log", lxcpath, name, name);
#else
if (lxcpath == default_lxc_path())
ret = snprintf(p, len, "%s/%s.log", lxcpath, name);
else
ret = snprintf(p, len, "%s/%s/%s.log", lxcpath, name, name);
#endif
Well, that or we use $lxcpath/logs/$name.log, but I prefer to keep the
rule: we either use $LOGPATH/$name.log, or else
$lxcpath/$name/$name.log, always.
Thoughts?
thanks,
-serge
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Lxc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxc-devel