diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-06-16 23:09:03 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2009-06-16 23:09:03 +0000 |
commit | 4c97a6fafadc478465e584c691455a19d9c9ee66 (patch) | |
tree | 825556f971c845354724ca4d7f18a45452b5ad24 /cmdutils.c | |
parent | 77ddf4df944cf14e6f5cc3d407d383e7e4dc0de0 (diff) | |
download | ffmpeg-4c97a6fafadc478465e584c691455a19d9c9ee66.tar.gz |
Move opt_loglevel() from ffmpeg.c to cmdutils.c.
Originally committed as revision 19209 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'cmdutils.c')
-rw-r--r-- | cmdutils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c index bca7034fa7..3a84a14826 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -213,6 +213,41 @@ int opt_default(const char *opt, const char *arg){ return 0; } +int opt_loglevel(const char *opt, const char *arg) +{ + const struct { const char *name; int level; } const log_levels[] = { + { "quiet" , AV_LOG_QUIET }, + { "panic" , AV_LOG_PANIC }, + { "fatal" , AV_LOG_FATAL }, + { "error" , AV_LOG_ERROR }, + { "warning", AV_LOG_WARNING }, + { "info" , AV_LOG_INFO }, + { "verbose", AV_LOG_VERBOSE }, + { "debug" , AV_LOG_DEBUG }, + }; + char *tail; + int level; + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { + if (!strcmp(log_levels[i].name, arg)) { + av_log_set_level(log_levels[i].level); + return 0; + } + } + + level = strtol(arg, &tail, 10); + if (*tail) { + fprintf(stderr, "Invalid loglevel \"%s\". " + "Possible levels are numbers or:\n", arg); + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) + fprintf(stderr, "\"%s\"\n", log_levels[i].name); + exit(1); + } + av_log_set_level(level); + return 0; +} + void set_context_opts(void *ctx, void *opts_ctx, int flags) { int i; |