Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   log.c: factor out common parts from logMessageV() (http://www.linux-archive.org/centos/335800-log-c-factor-out-common-parts-logmessagev.html)

Ales Kozumplik 03-04-2010 01:08 PM

log.c: factor out common parts from logMessageV()
 
---
isys/log.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/isys/log.c b/isys/log.c
index 46d0931..2f921ba 100644
--- a/isys/log.c
+++ b/isys/log.c
@@ -95,6 +95,18 @@ static void printLogHeader(int level, FILE *outfile) {
}
}

+static void printLogMessage(int level, FILE *outfile, const char *s, va_list ap) {
+ printLogHeader(level, outfile);
+
+ va_list apc;
+ va_copy(apc, ap);
+ vfprintf(main_log_tty, s, apc);
+ va_end(apc);
+
+ fprintf(outfile, "
");
+ fflush(outfile);
+}
+
void logMessageV(int level, const char * s, va_list ap) {
va_list apc;
/* Log everything into syslog */
@@ -104,22 +116,12 @@ void logMessageV(int level, const char * s, va_list ap) {

/* Only log to the screen things that are above the minimum level. */
if (main_log_tty && level >= minLevel) {
- printLogHeader(level, main_log_tty);
- va_copy(apc, ap);
- vfprintf(main_log_tty, s, apc);
- va_end(apc);
- fprintf(main_log_tty, "
");
- fflush(main_log_tty);
+ printLogMessage(level, main_log_tty, s, ap);
}

/* But log everything to the file. */
if (main_log_file) {
- printLogHeader(level, main_log_file);
- va_copy(apc, ap);
- vfprintf(main_log_file, s, apc);
- va_end(apc);
- fprintf(main_log_file, "
");
- fflush(main_log_file);
+ printLogMessage(level, main_log_file, s, ap);
}
}

--
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Martin Sivak 03-08-2010 11:12 AM

log.c: factor out common parts from logMessageV()
 
Looks OK.
Martin

----- "Ales Kozumplik" <akozumpl@redhat.com> wrote:

> ---
> isys/log.c | 26 ++++++++++++++------------
> 1 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/isys/log.c b/isys/log.c
> index 46d0931..2f921ba 100644
> --- a/isys/log.c
> +++ b/isys/log.c
> @@ -95,6 +95,18 @@ static void printLogHeader(int level, FILE
> *outfile) {
> }
> }
>
> +static void printLogMessage(int level, FILE *outfile, const char *s,
> va_list ap) {
> + printLogHeader(level, outfile);
> +
> + va_list apc;
> + va_copy(apc, ap);
> + vfprintf(main_log_tty, s, apc);
> + va_end(apc);
> +
> + fprintf(outfile, "
");
> + fflush(outfile);
> +}
> +
> void logMessageV(int level, const char * s, va_list ap) {
> va_list apc;
> /* Log everything into syslog */
> @@ -104,22 +116,12 @@ void logMessageV(int level, const char * s,
> va_list ap) {
>
> /* Only log to the screen things that are above the minimum
> level. */
> if (main_log_tty && level >= minLevel) {
> - printLogHeader(level, main_log_tty);
> - va_copy(apc, ap);
> - vfprintf(main_log_tty, s, apc);
> - va_end(apc);
> - fprintf(main_log_tty, "
");
> - fflush(main_log_tty);
> + printLogMessage(level, main_log_tty, s, ap);
> }
>
> /* But log everything to the file. */
> if (main_log_file) {
> - printLogHeader(level, main_log_file);
> - va_copy(apc, ap);
> - vfprintf(main_log_file, s, apc);
> - va_end(apc);
> - fprintf(main_log_file, "
");
> - fflush(main_log_file);
> + printLogMessage(level, main_log_file, s, ap);
> }
> }
>
> --
> 1.6.6
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 03:38 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.