Revision 4c97a6fa

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;
cmdutils.h
51 51
int opt_default(const char *opt, const char *arg);
52 52

  
53 53
/**
54
 * Sets the libav* libraries log level.
55
 */
56
int opt_loglevel(const char *opt, const char *arg);
57

  
58
/**
54 59
 * Parses a string and returns its corresponding value as a double.
55 60
 * Exits from the application if the string cannot be correctly
56 61
 * parsed or the corresponding value is invalid.
ffmpeg.c
2354 2354
    return 0;
2355 2355
}
2356 2356

  
2357
static int opt_loglevel(const char *opt, const char *arg)
2358
{
2359
    const struct { const char *name; int level; } const log_levels[] = {
2360
        { "quiet"  , AV_LOG_QUIET   },
2361
        { "panic"  , AV_LOG_PANIC   },
2362
        { "fatal"  , AV_LOG_FATAL   },
2363
        { "error"  , AV_LOG_ERROR   },
2364
        { "warning", AV_LOG_WARNING },
2365
        { "info"   , AV_LOG_INFO    },
2366
        { "verbose", AV_LOG_VERBOSE },
2367
        { "debug"  , AV_LOG_DEBUG   },
2368
    };
2369
    char *tail;
2370
    int level;
2371
    int i;
2372

  
2373
    for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
2374
        if (!strcmp(log_levels[i].name, arg)) {
2375
            av_log_set_level(log_levels[i].level);
2376
            return 0;
2377
        }
2378
    }
2379

  
2380
    level = strtol(arg, &tail, 10);
2381
    if (*tail) {
2382
        fprintf(stderr, "Invalid loglevel \"%s\". "
2383
                        "Possible levels are numbers or:\n", arg);
2384
        for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
2385
            fprintf(stderr, "\"%s\"\n", log_levels[i].name);
2386
        av_exit(1);
2387
    }
2388
    av_log_set_level(level);
2389
    return 0;
2390
}
2391

  
2392 2357
static int opt_verbose(const char *opt, const char *arg)
2393 2358
{
2394 2359
    verbose = parse_number_or_die(opt, arg, OPT_INT64, -10, 10);

Also available in: Unified diff