[PATCH 1/4] lib: fwts_log: add extra log types and upper case flavour of fwts_log_field_to_str_full()

IvanHu ivan.hu at canonical.com
Fri Jun 1 06:35:17 UTC 2012


On 05/31/2012 02:40 AM, Colin King wrote:
> From: Colin Ian King<colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king at canonical.com>
> ---
>   src/lib/include/fwts_log.h |   10 ++++++++--
>   src/lib/src/fwts_log.c     |   39 +++++++++++++++++++++++++++++++++++++++
>   2 files changed, 47 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/include/fwts_log.h b/src/lib/include/fwts_log.h
> index 8027d41..4e0f33a 100644
> --- a/src/lib/include/fwts_log.h
> +++ b/src/lib/include/fwts_log.h
> @@ -37,6 +37,11 @@ typedef enum {
>   	LOG_ADVICE          = 0x00000100,
>   	LOG_HEADING	    = 0x00000200,
>   	LOG_TAG		    = 0x00000400,
> +	LOG_PASSED	    = 0x00000800,
> +	LOG_FAILED	    = 0x00001000,
> +	LOG_SKIPPED	    = 0x00002000,
> +	LOG_ABORTED	    = 0x00004000,
> +	LOG_INFOONLY	    = 0x00008000, /* no-op */
>
>   	LOG_FIELD_MASK	    = 0x0000ffff,
>
> @@ -62,7 +67,7 @@ typedef enum {
>
>   typedef struct log_t {
>   	unsigned int magic;
> -	FILE *fp;	
> +	FILE *fp;
>   	char *owner;
>   	int line_width;
>   	int line_number;
> @@ -104,6 +109,7 @@ fwts_log_field fwts_log_str_to_field(const char *text);
>   char     *fwts_log_level_to_str(const fwts_log_level level);
>   char	 *fwts_log_field_to_str(const fwts_log_field field);
>   char     *fwts_log_field_to_str_full(const fwts_log_field field);
> +char	 *fwts_log_field_to_str_upper(const fwts_log_field field);
>   int 	  fwts_log_line_number(fwts_log *log);
>   void	  fwts_log_set_line_width(const int width);
>   void	  fwts_log_section_begin(fwts_log *log, const char *name);
> @@ -117,7 +123,7 @@ void	  fwts_log_section_end(fwts_log *log);
>
>   #define fwts_log_warning_verbatum(fw, fmt, args...)	\
>   	fwts_log_printf(fw->results, LOG_WARNING | LOG_VERBATUM, LOG_LEVEL_NONE, "", "", "", fmt, ## args)
> -	
> +
>   #define fwts_log_error(fw, fmt, args...)	\
>   	fwts_log_printf(fw->results, LOG_ERROR, LOG_LEVEL_NONE, "", "", "", fmt, ## args)
>
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 2b11441..c764d55 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -25,6 +25,7 @@
>   #include<unistd.h>
>   #include<sys/ioctl.h>
>   #include<time.h>
> +#include<ctype.h>
>
>   #include "fwts.h"
>
> @@ -84,6 +85,16 @@ char *fwts_log_field_to_str(const fwts_log_field field)
>   		return "HED";
>   	case LOG_TAG:
>   		return "TAG";
> +	case LOG_PASSED:
> +		return "PAS";
> +	case LOG_FAILED:
> +		return "FAL";
> +	case LOG_SKIPPED:
> +		return "SKP";
> +	case LOG_ABORTED:
> +		return "ABT";
> +	case LOG_INFOONLY:
> +		return "INO";
>   	default:
>   		return LOG_UNKOWN_FIELD;
>   	}
> @@ -118,12 +129,40 @@ char *fwts_log_field_to_str_full(const fwts_log_field field)
>   		return "Heading";
>   	case LOG_TAG:
>   		return "Tag";
> +	case LOG_PASSED:
> +		return "Passed";
> +	case LOG_FAILED:
> +		return "Failed";
> +	case LOG_SKIPPED:
> +		return "Skipped";
> +	case LOG_ABORTED:
> +		return "Aborted";
> +	case LOG_INFOONLY:
> +		return "Info Only";
>   	default:
>   		return "Unknown";
>   	}
>   }
>
>   /*
> + *  fwts_log_field_to_str_full()
> + *	return full string name of log field
> + */
> +char *fwts_log_field_to_str_upper(const fwts_log_field field)
> +{
> +	static char str[16];
> +	char *ptr1 = str;
> +	char *ptr2 = fwts_log_field_to_str_full(field);
> +
> +	for (ptr1 = str; *ptr2; ptr1++, ptr2++)
> +		*ptr1 = toupper(*ptr2);
> +
> +	*ptr1 = '\0';
> +
> +	return str;
> +}
> +
> +/*
>    *  fwts_log_str_to_level()
>    *	return log level mapped from the given string
>    */
Acked-by: Ivan Hu<ivan.hu at canonical.com>




More information about the fwts-devel mailing list