Align console output routines with upstream
They're not quite the same yet, but the diff is much smaller.
BUG=chromium:478356
BRANCH=none
TEST=still builds
Change-Id: I7c852b40a7d3d5f35f0bd50c322ffa6299f60af7
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/437429
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
diff --git a/cli_output.c b/cli_output.c
index 424721c..9ddb606 100644
--- a/cli_output.c
+++ b/cli_output.c
@@ -36,7 +36,7 @@
if (fclose(logfile)) {
/* fclose returned an error. Stop writing to be safe. */
logfile = NULL;
- msg_perr("Closing the log file returned error %s\n", strerror(errno));
+ msg_gerr("Closing the log file returned error %s\n", strerror(errno));
return 1;
}
logfile = NULL;
@@ -46,7 +46,7 @@
int open_logfile(const char * const filename)
{
if (!filename) {
- msg_gerr("No filename specified.\n");
+ msg_gerr("No logfile name specified.\n");
return 1;
}
if ((logfile = fopen(filename, "w")) == NULL) {
@@ -60,24 +60,25 @@
{
int oldverbose_screen = verbose_screen;
- /* make the console quieter. */
+ /* Shut up the console. */
verbose_screen = MSG_ERROR;
print_version();
verbose_screen = oldverbose_screen;
}
#endif /* !STANDALONE */
-int print(int type, const char *fmt, ...)
+/* Please note that level is the verbosity, not the importance of the message. */
+int print(enum msglevel level, const char *fmt, ...)
{
va_list ap;
int ret;
FILE *output_type;
- switch (type) {
+ switch (level) {
case MSG_ERROR:
output_type = stderr;
break;
- case MSG_BARF:
+ case MSG_SPEW:
if (verbose_screen < 3)
return 0;
case MSG_DEBUG2:
@@ -98,14 +99,13 @@
fflush(output_type);
#ifndef STANDALONE
- if ((type <= verbose_logfile) && logfile) {
+ if ((level <= verbose_logfile) && logfile) {
va_start(ap, fmt);
ret = vfprintf(logfile, fmt, ap);
va_end(ap);
- if (type != MSG_BARF)
+ if (level != MSG_SPEW)
fflush(logfile);
}
#endif /* !STANDALONE */
-
return ret;
}