diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-08-17 11:21:11 +0530 |
---|---|---|
committer | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2017-08-17 14:22:55 +0530 |
commit | b535c44fdd2b71c50a8fcbcf1e1e1c2d1c0340e9 (patch) | |
tree | 208d639723c7a8bfc1b928ee7843155c69fe8a5e /utils/utils.h | |
parent | d723907c8eaa25f107c7fadd79ca5f9bc6596edf (diff) |
logger: support logdir choosing via Environment variable
Currently the default logdir is DATADIR /log/gluster-block/
This patch will provide a way to change this default logdir via Env variable
$ export GB_LOGDIR=/var/log/gluster-block-new-path/
Note: make sure to restart the processes (cli & daemon) after you set GB_LOGDIR
Change-Id: Id142e4a4dfe7b6ebc9cf8296b8ceb8bff37691b8
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'utils/utils.h')
-rw-r--r-- | utils/utils.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/utils/utils.h b/utils/utils.h index 1d82963..8e951fd 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -22,8 +22,28 @@ # include <unistd.h> # include <errno.h> # include <time.h> +# include <limits.h> # include <sys/time.h> +# define GB_LOGDIR DATADIR "/log/gluster-block" +# define GB_INFODIR DATADIR "/run" + +# define GB_LOCK_FILE GB_INFODIR "/gluster-blockd.lock" +# define GB_UNIX_ADDRESS GB_INFODIR "/gluster-blockd.socket" +# define GB_TCP_PORT 24006 + +# define GFAPI_LOG_LEVEL 7 + +# define DEVNULLPATH "/dev/null" + +# define GB_METADIR "/block-meta" +# define GB_STOREDIR "/block-store" +# define GB_TXLOCKFILE "meta.lock" + +# define GB_MAX_LOGFILENAME 64 /* max strlen of file name */ + +# define SUN_PATH_MAX (sizeof(struct sockaddr_un) - sizeof(unsigned short int)) /*sun_family*/ + # define GB_TIME_STRING_BUFLEN \ (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 6 + 1 + 5) /* Yr Mon Day Hour Min Sec Ms NULL Round-off(32) @@ -83,19 +103,29 @@ fprintf(stdout, fmt, __VA_ARGS__); \ } while (0) -extern size_t logLevel; + +struct gbConf { + int logLevel; + char logDir[PATH_MAX]; + char daemonLogFile[PATH_MAX]; + char cliLogFile[PATH_MAX]; + char gfapiLogFile[PATH_MAX]; + char configShellLogFile[PATH_MAX]; +}; + +extern struct gbConf gbConf; # define LOG(str, level, fmt, ...) \ do { \ FILE *fd; \ char timestamp[GB_TIME_STRING_BUFLEN] = {0}; \ - if (level <= logLevel) { \ + if (level <= gbConf.logLevel) { \ if (!strcmp(str, "mgmt")) \ - fd = fopen (DAEMON_LOG_FILE, "a"); \ - else if (strcmp(str, "cli")) \ - fd = fopen (CLI_LOG_FILE, "a"); \ - else if (strcmp(str, "gfapi")) \ - fd = fopen (GFAPI_LOG_FILE, "a"); \ + fd = fopen (gbConf.daemonLogFile, "a"); \ + else if (!strcmp(str, "cli")) \ + fd = fopen (gbConf.cliLogFile, "a"); \ + else if (!strcmp(str, "gfapi")) \ + fd = fopen (gbConf.gfapiLogFile, "a"); \ else \ fd = stderr; \ if (fd == NULL) { \ @@ -406,6 +436,8 @@ int blockRemoteCreateRespEnumParse(const char *opt); void logTimeNow(char* buf, size_t bufSize); +int initLogging(void); + int gbAlloc(void *ptrptr, size_t size, const char *filename, const char *funcname, size_t linenr); |