From: Adam Dickmeiss Date: Thu, 29 Aug 2002 09:58:42 +0000 (+0000) Subject: Added yaz_log_init_prefix2 X-Git-Tag: YAZ.1.9~22 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=cdf2ebfab56b50232a49bc4032d90704794ca4c0;p=yaz-moved-to-github.git Added yaz_log_init_prefix2 --- diff --git a/include/yaz/log.h b/include/yaz/log.h index 22f7ada..6b41af3 100644 --- a/include/yaz/log.h +++ b/include/yaz/log.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: log.h,v 1.6 2002-06-18 21:30:39 adam Exp $ + * $Id: log.h,v 1.7 2002-08-29 09:58:42 adam Exp $ */ #ifndef LOG_H @@ -54,6 +54,7 @@ YAZ_EXPORT void yaz_log_init(int level, const char *prefix, const char *name); YAZ_EXPORT void yaz_log_init_file (const char *fname); YAZ_EXPORT void yaz_log_init_level (int level); YAZ_EXPORT void yaz_log_init_prefix (const char *prefix); +YAZ_EXPORT void yaz_log_init_prefix2 (const char *prefix); YAZ_EXPORT void yaz_log(int level, const char *fmt, ...) #ifdef __GNUC__ diff --git a/util/log.c b/util/log.c index 46412af..42e1167 100644 --- a/util/log.c +++ b/util/log.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: log.c,v 1.27 2002-06-18 21:30:39 adam Exp $ + * $Id: log.c,v 1.28 2002-08-29 09:58:42 adam Exp $ */ #if HAVE_CONFIG_H @@ -38,6 +38,7 @@ char *strerror(int n) static int l_level = LOG_DEFAULT_LEVEL; static FILE *l_file = NULL; static char l_prefix[512] = ""; +static char l_prefix2[512] = ""; static struct { int mask; @@ -92,6 +93,14 @@ void yaz_log_init_prefix (const char *prefix) *l_prefix = 0; } +void yaz_log_init_prefix2 (const char *prefix) +{ + if (prefix && *prefix) + sprintf(l_prefix2, "%.511s ", prefix); + else + *l_prefix2 = 0; +} + void yaz_log_init(int level, const char *prefix, const char *fname) { yaz_log_init_level (level); @@ -176,7 +185,8 @@ void yaz_log(int level, const char *fmt, ...) ti = time(0); tim = localtime(&ti); strftime(tbuf, 50, "%H:%M:%S-%d/%m", tim); - fprintf(l_file, "%s: %s%s %s\n", tbuf, l_prefix, flags, buf); + fprintf(l_file, "%s: %s%s %s%s\n", tbuf, l_prefix, flags, + l_prefix2, buf); fflush(l_file); if (end_hook_func) (*end_hook_func)(o_level, buf, end_hook_info);