diff --git a/contrib/largeNbDicts/largeNbDicts.c b/contrib/largeNbDicts/largeNbDicts.c index 6b6cc34ca11..30c1396ec39 100644 --- a/contrib/largeNbDicts/largeNbDicts.c +++ b/contrib/largeNbDicts/largeNbDicts.c @@ -45,7 +45,9 @@ #define RUN_TIME_DEFAULT_MS 1000 #define BENCH_TIME_DEFAULT_MS (BENCH_TIME_DEFAULT_S * RUN_TIME_DEFAULT_MS) -#define DISPLAY_LEVEL_DEFAULT 3 +#ifndef ZSTD_DISPLAY_LEVEL_DEFAULT +# define ZSTD_DISPLAY_LEVEL_DEFAULT 3 +#endif #define BENCH_SIZE_MAX (1200 MB) @@ -61,7 +63,7 @@ #define DISPLAY(...) fprintf(stdout, __VA_ARGS__) #define DISPLAYLEVEL(l, ...) { if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); } } -static int g_displayLevel = DISPLAY_LEVEL_DEFAULT; /* 0 : no display, 1: errors, 2 : + result + interaction + warnings, 3 : + progression, 4 : + information */ +static int g_displayLevel = ZSTD_DISPLAY_LEVEL_DEFAULT; /* 0 : no display, 1: errors, 2 : + result + interaction + warnings, 3 : + progression, 4 : + information */ /*--- buffer_t ---*/ diff --git a/programs/README.md b/programs/README.md index 2a6978ac456..6522b647dd3 100644 --- a/programs/README.md +++ b/programs/README.md @@ -79,6 +79,13 @@ There are however other Makefile targets that create different variations of CLI This can be useful to produce smaller binaries. A corresponding `Makefile` target using this ability is `zstd-compress`. +- __ZSTD_DISPLAY_LEVEL_DEFAULT__ : Controls the default verbosity level of `zstd` output. + The default value is `2`. Lower values (e.g., `1`) reduce output verbosity, + while higher values (e.g., `3`) increase it. + This allows setting preferred verbosity at compile time, + rather than passing `-q` or `-v` flags at runtime. + Example : `CPPFLAGS="-DZSTD_DISPLAY_LEVEL_DEFAULT=1" make` + - __BACKTRACE__ : `zstd` can display a stack backtrace when execution generates a runtime exception. By default, this feature may be degraded/disabled on some platforms unless additional compiler directives are diff --git a/programs/fileio.c b/programs/fileio.c index a0dcad81745..78a906d533b 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2401,7 +2401,9 @@ int FIO_compressFilename(FIO_ctx_t* const fCtx, FIO_prefs_t* const prefs, const cRess_t ress = FIO_createCResources(prefs, dictFileName, UTIL_getFileSize(srcFileName), compressionLevel, comprParams); int const result = FIO_compressFilename_srcFile(fCtx, prefs, &ress, dstFileName, srcFileName, compressionLevel); -#define DISPLAY_LEVEL_DEFAULT 2 +#ifndef ZSTD_DISPLAY_LEVEL_DEFAULT +# define ZSTD_DISPLAY_LEVEL_DEFAULT 2 +#endif FIO_freeCResources(&ress); return result; diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 34db7bf51a0..1be8fc26b4b 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -77,7 +77,9 @@ static unsigned init_nbWorkers(unsigned defaultNbWorkers); #define MB *(1 <<20) #define GB *(1U<<30) -#define DISPLAY_LEVEL_DEFAULT 2 +#ifndef ZSTD_DISPLAY_LEVEL_DEFAULT +# define ZSTD_DISPLAY_LEVEL_DEFAULT 2 +#endif static const char* g_defaultDictName = "dictionary"; static const unsigned g_defaultMaxDictSize = 110 KB; @@ -104,7 +106,7 @@ typedef enum { cover, fastCover, legacy } dictType; **************************************/ #undef DISPLAYLEVEL #define DISPLAYLEVEL(l, ...) { if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); } } -static int g_displayLevel = DISPLAY_LEVEL_DEFAULT; /* 0 : no display, 1: errors, 2 : + result + interaction + warnings, 3 : + progression, 4 : + information */ +static int g_displayLevel = ZSTD_DISPLAY_LEVEL_DEFAULT; /* 0 : no display, 1: errors, 2 : + result + interaction + warnings, 3 : + progression, 4 : + information */ /*-************************************ @@ -660,7 +662,7 @@ static void setMaxCompression(ZSTD_compressionParameters* params) static void printVersion(void) { - if (g_displayLevel < DISPLAY_LEVEL_DEFAULT) { + if (g_displayLevel < ZSTD_DISPLAY_LEVEL_DEFAULT) { DISPLAYOUT("%s\n", ZSTD_VERSION_STRING); return; }