Skip to content

Commit f3400a8

Browse files
committed
more logging improvements and guidance in docs
1 parent 1deb2eb commit f3400a8

File tree

9 files changed

+23
-22
lines changed

9 files changed

+23
-22
lines changed

src/core/plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ struct PluginManager::PluginManagerPrivate {
113113
fs::path resolved = resolver->resolve(filename);
114114

115115
if (fs::exists(resolved)) {
116-
Log(Debug, "Loading plugin \"%s\" ..", filename.string());
116+
Log(Debug, "Loading plugin \"%s\" from \"%s\" ..", name, resolved.string());
117117
Plugin *plugin = new Plugin(resolved);
118118
// New classes must be registered within the class hierarchy
119119
Class::static_initialization();

src/core/spectrum.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ void spectrum_from_file(const fs::path &path, std::vector<Scalar> &wavelengths,
1313
auto fs = Thread::thread()->file_resolver();
1414
fs::path file_path = fs->resolve(path);
1515
if (!fs::exists(file_path))
16-
Log(Error, "\"%s\": file does not exist!", file_path);
16+
Log(Error, "\"%s\": file does not exist!", file_path.string());
1717

18-
Log(Info, "Loading spectral data file \"%s\" ..", file_path);
18+
Log(Info, "Loading spectral data file \"%s\" ..", file_path.string());
1919
std::string extension = string::to_lower(file_path.extension().string());
2020
if (extension == ".spd") {
2121
ref<MemoryMappedFile> mmap = new MemoryMappedFile(file_path, false);

src/core/tensor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TensorFile::TensorFile(const fs::path &filename)
2121
Throw("Invalid tensor file: unknown file version.");
2222

2323
Log(Info, "Loading tensor data from \"%s\" .. (%s, %i field%s)",
24-
filename.filename(), util::mem_string(stream->size()), n_fields,
24+
filename.string(), util::mem_string(stream->size()), n_fields,
2525
n_fields > 1 ? "s" : "");
2626

2727
for (uint32_t i = 0; i < n_fields; ++i) {

src/emitters/envmap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class EnvironmentMapEmitter final : public Emitter<Float, Spectrum> {
108108
ref<Bitmap> bitmap = new Bitmap(file_path);
109109
if (bitmap->width() < 2 || bitmap->height() < 3)
110110
Throw("\"%s\": the environment map resolution must be at "
111-
"least 2x3 pixels", m_filename);
111+
"least 2x3 pixels", file_path.string());
112112

113113
/* Convert to linear RGBA float bitmap, will undergo further
114114
conversion into coefficients of a spectral upsampling model below */

src/render/srgb.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ dr::Array<float, 3> srgb_model_fetch(const Color<float, 3> &c) {
2020
FileResolver *fr = Thread::thread()->file_resolver();
2121
std::string fname = fr->resolve("data/srgb.coeff").string();
2222
if (!fs::exists(fname))
23-
Throw("Could not find sRGB-to-spectrum upsampling model ('data/srgb.coeff')");
24-
Log(Info, "Loading spectral upsampling model \"data/srgb.coeff\" .. ");
23+
Throw("Could not find sRGB-to-spectrum upsampling model (\"data/srgb.coeff\")");
24+
Log(Info, "Loading spectral upsampling model \"%s\" .. ", fname);
2525
model = rgb2spec_load(fname.c_str());
2626
if (model == nullptr)
27-
Throw("Could not load sRGB-to-spectrum upsampling model ('%s')", fname.c_str());
27+
Throw("Could not load sRGB-to-spectrum upsampling model (\"%s\")", fname);
2828
atexit([]{ rgb2spec_free(model); });
2929
}
3030
}

src/shapes/obj.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ class OBJMesh final : public Mesh<Float, Spectrum> {
155155

156156
auto fail = [&](const char *descr, auto... args) {
157157
Throw(("Error while loading OBJ file \"%s\": " + std::string(descr))
158-
.c_str(), m_name, args...);
158+
.c_str(), file_path.string(), args...);
159159
};
160160

161-
Log(Debug, "Loading mesh from \"%s\" ..", m_name);
161+
Log(Debug, "Loading mesh from \"%s\" ..", file_path.string());
162162
if (!fs::exists(file_path))
163163
fail("file not found");
164164

@@ -378,7 +378,7 @@ class OBJMesh final : public Mesh<Float, Spectrum> {
378378
vertex_data_bytes += 2 * sizeof(InputFloat);
379379

380380
Log(Debug, "\"%s\": read %i faces, %i vertices (%s in %s)",
381-
m_name, m_face_count, m_vertex_count,
381+
file_path.string(), m_face_count, m_vertex_count,
382382
util::mem_string(m_face_count * 3 * sizeof(ScalarIndex) +
383383
m_vertex_count * vertex_data_bytes),
384384
util::time_string((float) timer.value())
@@ -387,7 +387,7 @@ class OBJMesh final : public Mesh<Float, Spectrum> {
387387
if (!m_face_normals && normals.empty()) {
388388
Timer timer2;
389389
recompute_vertex_normals();
390-
Log(Debug, "\"%s\": computed vertex normals (took %s)", m_name,
390+
Log(Debug, "\"%s\": computed vertex normals (took %s)", file_path.string(),
391391
util::time_string((float) timer2.value()));
392392
}
393393

src/shapes/ply.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ class PLYMesh final : public Mesh<Float, Spectrum> {
170170
m_name = file_path.filename().string();
171171

172172
auto fail = [&](const char *descr) {
173-
Throw("Error while loading PLY file \"%s\": %s!", m_name, descr);
173+
Throw("Error while loading PLY file \"%s\": %s!", file_path.string(), descr);
174174
};
175175

176-
Log(Debug, "Loading mesh from \"%s\" ..", m_name);
176+
Log(Debug, "Loading mesh from \"%s\" ..", file_path.string());
177177
if (!fs::exists(file_path))
178178
fail("file not found");
179179

@@ -189,7 +189,7 @@ class PLYMesh final : public Mesh<Float, Spectrum> {
189189
Log(Warn,
190190
"\"%s\": performance warning -- this file uses the ASCII PLY format, which "
191191
"is slow to parse. Consider converting it to the binary PLY format.",
192-
m_name);
192+
file_path.string());
193193
stream = parse_ascii((FileStream *) stream.get(), header.elements);
194194
}
195195
} catch (const std::exception &e) {
@@ -417,7 +417,7 @@ class PLYMesh final : public Mesh<Float, Spectrum> {
417417

418418
m_faces = dr::load<DynamicBuffer<UInt32>>(faces.get(), m_face_count * 3);
419419
} else {
420-
Log(Warn, "\"%s\": skipping unknown element \"%s\"", m_name, el.name);
420+
Log(Warn, "\"%s\": skipping unknown element \"%s\"", file_path.string(), el.name);
421421
stream->seek(stream->tell() + el.struct_->size() * el.count);
422422
}
423423
}
@@ -426,7 +426,7 @@ class PLYMesh final : public Mesh<Float, Spectrum> {
426426
fail("invalid file -- trailing content");
427427

428428
Log(Debug, "\"%s\": read %i faces, %i vertices (%s in %s)",
429-
m_name, m_face_count, m_vertex_count,
429+
file_path.string(), m_face_count, m_vertex_count,
430430
util::mem_string(m_face_count * face_struct->size() +
431431
m_vertex_count * vertex_struct->size()),
432432
util::time_string((float) timer.value())
@@ -435,7 +435,7 @@ class PLYMesh final : public Mesh<Float, Spectrum> {
435435
if (!m_face_normals && !has_vertex_normals) {
436436
Timer timer2;
437437
recompute_vertex_normals();
438-
Log(Debug, "\"%s\": computed vertex normals (took %s)", m_name,
438+
Log(Debug, "\"%s\": computed vertex normals (took %s)", file_path.string(),
439439
util::time_string((float) timer2.value()));
440440
}
441441

src/shapes/serialized.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,13 @@ class SerializedMesh final : public Mesh<Float, Spectrum> {
235235
}
236236

237237
SerializedMesh(const Properties &props) : Base(props) {
238+
auto fs = Thread::thread()->file_resolver();
239+
fs::path file_path = fs->resolve(props.string("filename"));
240+
238241
auto fail = [&](const std::string &descr) {
239-
Throw("Error while loading serialized file \"%s\": %s!", m_name, descr);
242+
Throw("Error while loading serialized file \"%s\": %s!", file_path.string(), descr);
240243
};
241244

242-
auto fs = Thread::thread()->file_resolver();
243-
fs::path file_path = fs->resolve(props.string("filename"));
244245
m_name = file_path.filename().string();
245246

246247
Log(Debug, "Loading mesh from \"%s\" ..", m_name);

src/textures/bitmap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class BitmapTexture final : public Texture<Float, Spectrum> {
138138
FileResolver* fs = Thread::thread()->file_resolver();
139139
fs::path file_path = fs->resolve(props.string("filename"));
140140
m_name = file_path.filename().string();
141-
Log(Debug, "Loading bitmap texture from \"%s\" ..", m_name);
141+
Log(Debug, "Loading bitmap texture from \"%s\" ..", file_path.string());
142142
m_bitmap = new Bitmap(file_path);
143143
}
144144

0 commit comments

Comments
 (0)