Repository: ossrs/srs
File: trunk/src/app/srs_app_config.cpp (C++)

Code before:
        try_config_files.push_back("/etc/srs/srs.conf");

        // Match the first exists file.
        string exists_config_file;
        for (int i = 0; i < (int) try_config_files.size(); i++) {
            string try_config_file = try_config_files.at(i);
            if (srs_path_exists(try_config_file)) {
                exists_config_file = try_config_file;
                break;
            }
        }

        if (exists_config_file.empty()) {
            return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "no config file at %s", srs_join_vector_string(try_config_files, ", ").c_str());
        }

        if (config_file != exists_config_file) {
            srs_warn("user config %s does not exists, use %s instead", config_file.c_str(), exists_config_file.c_str());
            config_file = exists_config_file;
        }
    }

    // Parse the matched config file.
    if ((err = parse_file(config_file.c_str())) != srs_success) {
        return srs_error_wrap(err, "invalid config");
    }

    // transform config to compatible with previous style of config.
    if ((err = srs_config_transform_vhost(root)) != srs_success) {
        return srs_error_wrap(err, "transform");
    }

    if (test_conf) {
        // the parse_file never check the config,
        // we check it when user requires check config file.
        if ((err = check_config()) == srs_success) {
            srs_trace("config file is ok");
            exit(0);
        }

        srs_error("config file, %s", srs_error_desc(err).c_str());
        exit(srs_error_code(err));
    }

    ////////////////////////////////////////////////////////////////////////
    // check log name and level
    ////////////////////////////////////////////////////////////////////////
    if (true) {
        std::string log_filename = this->get_log_file();
        if (get_log_tank_file() && log_filename.empty()) {
            return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "no log file");

Review comment (bug):
This is not the content to be submitted for PR, it is a bugfix. Please do not submit content that is unrelated to the PR.

Please undo this part of the code and submit a new one. Each PR corresponds to a branch.

`TRANS_BY_GPT3`

Code after:
        try_config_files.push_back("/etc/srs/srs.conf");

        // Match the first exists file.
        string exists_config_file;
        for (int i = 0; i < (int) try_config_files.size(); i++) {
            string try_config_file = try_config_files.at(i);
            if (srs_path_exists(try_config_file)) {
                exists_config_file = try_config_file;
                break;
            }
        }

        if (exists_config_file.empty()) {
            return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "no config file at %s", srs_join_vector_string(try_config_files, ", ").c_str());
        }

        if (config_file != exists_config_file) {
            srs_warn("user config %s does not exists, use %s instead", config_file.c_str(), exists_config_file.c_str());
            config_file = exists_config_file;
        }
    }

    // Parse the matched config file.
    err = parse_file(config_file.c_str());
    
    if (test_conf) {
        // the parse_file never check the config,
        // we check it when user requires check config file.
        if (err == srs_success && (err = srs_config_transform_vhost(root)) == srs_success) {
            if (err == srs_success && (err = check_config()) == srs_success) {
                srs_trace("config file is ok");
                exit(0);
            }
        }
        
        srs_error("invalid config, %s", srs_error_desc(err).c_str());
        int ret = srs_error_code(err);
        srs_freep(err);
        exit(ret);
    }
    
    // transform config to compatible with previous style of config.
    if ((err = srs_config_transform_vhost(root)) != srs_success) {
        return srs_error_wrap(err, "transform");
    }
    
    ////////////////////////////////////////////////////////////////////////
    // check log name and level
    ////////////////////////////////////////////////////////////////////////
    if (true) {
        std::string log_filename = this->get_log_file();