diff options
author | Clark Williams <williams@redhat.com> | 2020-10-22 23:22:18 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2020-10-22 23:22:18 -0500 |
commit | cf62c18061232359320260a3028612b33c4cb095 (patch) | |
tree | f24e5c0fb11770fd958a2cc4a7ad94b449c06675 | |
parent | c35b62722ffebb3cf16ad6b470d9275f007f6fa2 (diff) | |
download | stalld-cf62c18061232359320260a3028612b33c4cb095.tar.gz |
utils.c: added info() functions
Add info() to print only when config_verbose is set
Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r-- | src/stalld.h | 4 | ||||
-rw-r--r-- | src/utils.c | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/stalld.h b/src/stalld.h index 9a1cda4..a43e285 100644 --- a/src/stalld.h +++ b/src/stalld.h @@ -12,13 +12,14 @@ #define BUFFER_SIZE (100*1024) #define MAX_WAITING_PIDS 30 +#define COMM_SIZE 15 /* informnation about running tasks on a cpu */ struct task_info { int pid; int prio; int ctxsw; time_t since; - char comm[15]; + char comm[COMM_SIZE+1]; }; /* information about cpus */ @@ -92,6 +93,7 @@ static inline void normalize_timespec(struct timespec *ts) void die(const char *fmt, ...); void warn(const char *fmt, ...); +void info(const char *fmt, ...); void log_msg(const char *fmt, ...); long get_long_from_str(char *start); diff --git a/src/utils.c b/src/utils.c index d3fbc7a..1427446 100644 --- a/src/utils.c +++ b/src/utils.c @@ -193,6 +193,21 @@ void warn(const char *fmt, ...) } +/* + * print an informational message if config_verbose is true + */ +void info(const char *fmt, ...) +{ + va_list ap; + + if (config_verbose) { + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + } +} + + void log_msg(const char *fmt, ...) { |