1
1

Assets: log message when catalog definitions cannot be loaded

Log a message (via `CLOG`) when asset catalog definitions cannot be
loaded.

Reviewed by @jacqueslucke in D13633
This commit is contained in:
2021-12-21 15:48:05 +01:00
parent 7e712b2d6a
commit d66a6525c3
2 changed files with 24 additions and 0 deletions

View File

@@ -32,6 +32,10 @@
# include "BLI_winstuff.h"
#endif
#include "CLG_log.h"
static CLG_LogRef LOG = {"bke.asset_service"};
namespace blender::bke {
const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt";
@@ -311,6 +315,7 @@ void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_director
BLI_stat_t status;
if (BLI_stat(file_or_directory_path.data(), &status) == -1) {
/* TODO(@sybren): throw an appropriate exception. */
CLOG_WARN(&LOG, "path not found: %s", file_or_directory_path.data());
return;
}
@@ -337,6 +342,7 @@ void AssetCatalogService::load_directory_recursive(const CatalogFilePath &direct
if (!BLI_exists(file_path.data())) {
/* No file to be loaded is perfectly fine. */
CLOG_INFO(&LOG, 2, "path not found: %s", file_path.data());
return;
}
@@ -826,6 +832,10 @@ void AssetCatalogDefinitionFile::parse_catalog_file(
{
std::fstream infile(catalog_definition_file_path);
if (!infile.is_open()) {
CLOG_ERROR(&LOG, "%s: unable to open file", catalog_definition_file_path.c_str());
return;
}
bool seen_version_number = false;
std::string line;
while (std::getline(infile, line)) {

View File

@@ -27,6 +27,8 @@
#include "DNA_asset_types.h"
#include "DNA_userdef_types.h"
#include "CLG_log.h"
#include "testing/testing.h"
namespace blender::bke::tests {
@@ -93,6 +95,18 @@ class AssetCatalogTest : public testing::Test {
CatalogFilePath asset_library_root_;
CatalogFilePath temp_library_path_;
static void SetUpTestSuite()
{
testing::Test::SetUpTestSuite();
CLG_init();
}
static void TearDownTestSuite()
{
CLG_exit();
testing::Test::TearDownTestSuite();
}
void SetUp() override
{
const std::string test_files_dir = blender::tests::flags_test_asset_dir();