Revision 4c97a6fa cmdutils.c

View differences:

cmdutils.c
213 213
    return 0;
214 214
}
215 215

  
216
int opt_loglevel(const char *opt, const char *arg)
217
{
218
    const struct { const char *name; int level; } const log_levels[] = {
219
        { "quiet"  , AV_LOG_QUIET   },
220
        { "panic"  , AV_LOG_PANIC   },
221
        { "fatal"  , AV_LOG_FATAL   },
222
        { "error"  , AV_LOG_ERROR   },
223
        { "warning", AV_LOG_WARNING },
224
        { "info"   , AV_LOG_INFO    },
225
        { "verbose", AV_LOG_VERBOSE },
226
        { "debug"  , AV_LOG_DEBUG   },
227
    };
228
    char *tail;
229
    int level;
230
    int i;
231

  
232
    for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
233
        if (!strcmp(log_levels[i].name, arg)) {
234
            av_log_set_level(log_levels[i].level);
235
            return 0;
236
        }
237
    }
238

  
239
    level = strtol(arg, &tail, 10);
240
    if (*tail) {
241
        fprintf(stderr, "Invalid loglevel \"%s\". "
242
                        "Possible levels are numbers or:\n", arg);
243
        for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
244
            fprintf(stderr, "\"%s\"\n", log_levels[i].name);
245
        exit(1);
246
    }
247
    av_log_set_level(level);
248
    return 0;
249
}
250

  
216 251
void set_context_opts(void *ctx, void *opts_ctx, int flags)
217 252
{
218 253
    int i;

Also available in: Unified diff