i think all the old logging is replaced
parent
deacad5358
commit
78a4ad9f39
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/color.cmake)
|
||||
set(BLT_VERSION 5.2.6)
|
||||
set(BLT_VERSION 5.2.7)
|
||||
|
||||
set(BLT_TARGET BLT)
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace blt::nbt {
|
|||
auto& tag = t[i];
|
||||
T t;
|
||||
if (tag->getType() != t.getType()) {
|
||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
||||
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||
}
|
||||
return dynamic_cast<T*>(tag);
|
||||
|
@ -342,7 +342,7 @@ namespace blt::nbt {
|
|||
auto& tag = t[name];
|
||||
T t;
|
||||
if (tag->getType() != t.getType()) {
|
||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
||||
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||
}
|
||||
return dynamic_cast<T*>(tag);
|
||||
|
@ -409,7 +409,7 @@ namespace blt::nbt {
|
|||
auto& tag = root->get()[name];
|
||||
T t;
|
||||
if (tag->getType() != t.getType()) {
|
||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
||||
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||
}
|
||||
return dynamic_cast<T*>(tag);
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace blt
|
|||
*/
|
||||
inline void allocate_block()
|
||||
{
|
||||
//BLT_INFO("Allocating a new block of size %d", BLOCK_SIZE);
|
||||
//BLT_INFO("Allocating a new block of size {:d}", BLOCK_SIZE);
|
||||
auto* blk = new block_storage();
|
||||
blk->data = static_cast<pointer>(malloc(sizeof(T) * BLOCK_SIZE));
|
||||
blocks.push_back(blk);
|
||||
|
@ -572,13 +572,13 @@ namespace blt
|
|||
if constexpr (WARN_ON_FAIL)
|
||||
{
|
||||
if (((size_t) buffer & (HUGE_PAGE_SIZE - 1)) != 0)
|
||||
BLT_ERROR("Pointer is not aligned! %p", buffer);
|
||||
BLT_ERROR("Pointer is not aligned! {:#x}", buffer);
|
||||
}
|
||||
auto* ptr = static_cast<void*>(buffer);
|
||||
auto ptr_size = reinterpret_cast<blt::size_t>(ptr);
|
||||
buffer = static_cast<T*>(std::align(BLOCK_SIZE, BLOCK_SIZE, ptr, bytes));
|
||||
if constexpr (WARN_ON_FAIL)
|
||||
BLT_ERROR("Offset by %ld pages, resulting: %p", (reinterpret_cast<blt::size_t>(buffer) - ptr_size) / 4096, buffer);
|
||||
BLT_ERROR("Offset by {} pages, resulting: {:#x}", (reinterpret_cast<blt::size_t>(buffer) - ptr_size) / 4096, buffer);
|
||||
}
|
||||
return buffer;
|
||||
#endif
|
||||
|
@ -839,7 +839,7 @@ namespace blt
|
|||
#endif
|
||||
// if (deletes.contains(p))
|
||||
// {
|
||||
// BLT_FATAL("pointer %p has already been freed", p);
|
||||
// BLT_FATAL("pointer {:#x} has already been freed", p);
|
||||
// throw std::bad_alloc();
|
||||
// }else
|
||||
// deletes.insert(static_cast<void*>(p));
|
||||
|
@ -848,7 +848,7 @@ namespace blt
|
|||
blk->metadata.allocated_objects--;
|
||||
if (blk->metadata.allocated_objects == 0)
|
||||
{
|
||||
//BLT_INFO("Deallocating block from %p in (1) %p current head %p, based: %p", p, blk, head, base);
|
||||
//BLT_INFO("Deallocating block from {:#x} in (1) {:#x} current head {:#x}, based: {:#x}", p, blk, head, base);
|
||||
if (blk == base)
|
||||
{
|
||||
base = base->metadata.next;
|
||||
|
@ -860,7 +860,7 @@ namespace blt
|
|||
else if (blk->metadata.prev != nullptr) // finally if it wasn't the head we need to bridge the gap in the list
|
||||
blk->metadata.prev->metadata.next = blk->metadata.next;
|
||||
|
||||
//BLT_INFO("Deallocating block from %p in (2) %p current head %p, based: %p", p, blk, head, base);
|
||||
//BLT_INFO("Deallocating block from {:#x} in (2) {:#x} current head {:#x}, based: {:#x}", p, blk, head, base);
|
||||
delete_block(blk);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ std::string blt::fs::getFile(std::string_view path)
|
|||
file_contents = file_stream.str();
|
||||
} catch (std::ifstream::failure& e)
|
||||
{
|
||||
BLT_WARN("Unable to read file '%s'!\n", std::string(path).c_str());
|
||||
BLT_WARN("Exception: %s", e.what());
|
||||
BLT_WARN("Unable to read file '{}'!\n", std::string(path).c_str());
|
||||
BLT_WARN("Exception: {}", e.what());
|
||||
BLT_THROW(std::runtime_error("Failed to read file!\n"));
|
||||
}
|
||||
return file_contents;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace blt::nbt {
|
|||
char t;
|
||||
reader.read(&t, 1);
|
||||
if (t != (char)nbt_tag::COMPOUND) {
|
||||
BLT_WARN("Found %d", t);
|
||||
BLT_WARN("Found {:d}", t);
|
||||
throw std::runtime_error("Incorrectly formatted NBT data! Root tag must be a compound tag!");
|
||||
}
|
||||
root = new tag_compound;
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace blt
|
|||
printUsage();
|
||||
std::cout << getProgramName() << ": error: flag '" << flag << "' expected " << properties.a_nargs.args
|
||||
<< " argument(s) but found '" << tokenizer.get() << "' instead!\n";
|
||||
//BLT_WARN("Expected %d arguments, found flag instead!", properties.a_nargs.args);
|
||||
//BLT_WARN("Expected {:d} arguments, found flag instead!", properties.a_nargs.args);
|
||||
return false;
|
||||
}
|
||||
// get the value and advance
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace blt::parse
|
|||
private:
|
||||
std::string_view string;
|
||||
std::size_t current_pos = 0;
|
||||
|
||||
public:
|
||||
explicit char_tokenizer(std::string_view view): string(view)
|
||||
{}
|
||||
|
@ -55,14 +56,14 @@ namespace blt::parse
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T = float>
|
||||
template <typename T = float>
|
||||
T get(std::string_view str)
|
||||
{
|
||||
T x;
|
||||
// TODO: GCC version. C++17 supports from_chars but GCC8.5 doesn't have floating point.
|
||||
#if __cplusplus >= BLT_CPP20
|
||||
#if __cplusplus >= BLT_CPP20
|
||||
const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), x);
|
||||
#else
|
||||
#else
|
||||
auto ec = std::errc();
|
||||
if constexpr (std::is_floating_point_v<T>)
|
||||
{
|
||||
|
@ -73,20 +74,20 @@ namespace blt::parse
|
|||
} else
|
||||
static_assert(
|
||||
"You are using a c++ version which does not support the required std::from_chars, manual conversion has failed to find a type!");
|
||||
#endif
|
||||
#endif
|
||||
// probably not needed.
|
||||
if (ec != std::errc())
|
||||
{
|
||||
// int i;
|
||||
// const auto [ptr2, ec2] = std::from_chars(str.data(), str.data() + str.size(), i);
|
||||
// if (ec2 == std::errc())
|
||||
// {
|
||||
// x = static_cast<float>(i);
|
||||
// } else
|
||||
// {
|
||||
BLT_WARN("Unable to parse string '%s' into number!", std::string(str).c_str());
|
||||
// int i;
|
||||
// const auto [ptr2, ec2] = std::from_chars(str.data(), str.data() + str.size(), i);
|
||||
// if (ec2 == std::errc())
|
||||
// {
|
||||
// x = static_cast<float>(i);
|
||||
// } else
|
||||
// {
|
||||
BLT_WARN("Unable to parse string '{}' into number!", std::string(str).c_str());
|
||||
x = 0;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
@ -97,7 +98,7 @@ namespace blt::parse
|
|||
|
||||
if (type == 'p')
|
||||
{
|
||||
BLT_WARN("Unexpected type '%c' (not supported)", type);
|
||||
BLT_WARN("Unexpected type '{:c}' (not supported)", type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -160,14 +161,14 @@ namespace blt::parse
|
|||
case 'o':
|
||||
{
|
||||
current_object.object_names.emplace_back(token.read_fully());
|
||||
BLT_TRACE("Setting object '%s'", std::string(current_object.object_name).c_str());
|
||||
BLT_TRACE("Setting object '{}'", std::string(current_object.object_name).c_str());
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
while (token.has_next() && token.advance() != ' ')
|
||||
{}
|
||||
BLT_WARN("Material '%s' needs to be loaded!", std::string(token.read_fully()).c_str());
|
||||
BLT_WARN("Material '{}' needs to be loaded!", std::string(token.read_fully()).c_str());
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
|
@ -178,11 +179,11 @@ namespace blt::parse
|
|||
while (token.has_next() && token.advance() != ' ')
|
||||
{}
|
||||
current_object.material = token.read_fully();
|
||||
//BLT_WARN("Using material '%s'", std::string(token.read_fully()).c_str());
|
||||
//BLT_WARN("Using material '{}'", std::string(token.read_fully()).c_str());
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
//BLT_WARN("Using shading: %s", std::string(token.read_fully()).c_str());
|
||||
//BLT_WARN("Using shading: {}", std::string(token.read_fully()).c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +215,7 @@ namespace blt::parse
|
|||
current_object.indices.push_back(t1);
|
||||
current_object.indices.push_back(t2);
|
||||
} else
|
||||
BLT_WARN("Unsupported face vertex count of %d on line %d!", faces.size(), current_line);
|
||||
BLT_WARN("Unsupported face vertex count of {:d} on line {:d}!", faces.size(), current_line);
|
||||
}
|
||||
|
||||
void obj_loader::handle_face_vertex(const std::vector<std::string>& face_list, int32_t* arr)
|
||||
|
@ -228,7 +229,7 @@ namespace blt::parse
|
|||
auto ui = get<std::int32_t>(indices[1]) - 1;
|
||||
auto ni = get<std::int32_t>(indices[2]) - 1;
|
||||
|
||||
BLT_DEBUG("Found vertex: %d, UV: %d, and normal: %d", vi, ui, ni);
|
||||
BLT_DEBUG("Found vertex: {:d}, UV: {:d}, and normal: {:d}", vi, ui, ni);
|
||||
|
||||
face_t face{vi, ui, ni};
|
||||
|
||||
|
@ -238,16 +239,16 @@ namespace blt::parse
|
|||
BLT_DEBUG("DID NOT FIND FACE!");
|
||||
auto index = static_cast<std::int32_t>(vertex_data.size());
|
||||
vertex_data.push_back({vertices[vi], uvs[ui], normals[ni]});
|
||||
BLT_DEBUG("Vertex: (%f, %f, %f), UV: (%f, %f), Normal: (%f, %f, %f)", vertices[vi].x(), vertices[vi].y(), vertices[vi].z(),
|
||||
uvs[ui].x(), uvs[ui].y(), normals[ni].x(), normals[ni].y(), normals[ni].z());
|
||||
BLT_DEBUG("Vertex: ({.4f}, {.4f}, {.4f}), UV: ({.4f}, {.4f}), Normal: ({.4f}, {.4f}, {:.4f})", vertices[vi].x(), vertices[vi].y(),
|
||||
vertices[vi].z(), uvs[ui].x(), uvs[ui].y(), normals[ni].x(), normals[ni].y(), normals[ni].z());
|
||||
vertex_map.insert({face, index});
|
||||
arr[e_index] = index;
|
||||
} else
|
||||
{
|
||||
BLT_TRACE("Using cached data; %d; map size: %d", loc->second, vertex_data.size());
|
||||
BLT_TRACE("Using cached data; {:d}; map size: {:d}", loc->second, vertex_data.size());
|
||||
//const auto& d = vertex_data[loc->second];
|
||||
BLT_TRACE("Vertex: (%f, %f, %f), UV: (%f, %f), Normal: (%f, %f, %f)", d.vertex.x(), d.vertex.y(), d.vertex.z(),
|
||||
d.uv.x(), d.uv.y(), d.normal.x(), d.normal.y(), d.normal.z());
|
||||
BLT_TRACE("Vertex: ({.4f}, {.4f}, {.4f}), UV: ({.4f}, {.4f}), Normal: ({.4f}, {.4f}, {:.4f})", d.vertex.x(), d.vertex.y(),
|
||||
d.vertex.z(), d.uv.x(), d.uv.y(), d.normal.x(), d.normal.y(), d.normal.z());
|
||||
arr[e_index] = loc->second;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace blt
|
|||
values.push_back(b1 ^ b2);
|
||||
break;
|
||||
default:
|
||||
BLT_WARN("Unexpected token '%s'", std::string(next.token).c_str());
|
||||
BLT_WARN("Unexpected token '{}'", std::string(next.token).c_str());
|
||||
return blt::unexpected(template_parser_failure_t::BOOL_TYPE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace blt
|
|||
#ifdef IS_GNU_BACKTRACE
|
||||
BLT_STACK_TRACE(50);
|
||||
|
||||
BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line);
|
||||
BLT_ERROR("An exception '{}' has occurred in file '{}:{:d}'", what, path, line);
|
||||
BLT_ERROR("Stack Trace:");
|
||||
printStacktrace(messages, size, path, line);
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace blt
|
|||
#ifdef IS_GNU_BACKTRACE
|
||||
BLT_STACK_TRACE(50);
|
||||
|
||||
BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line);
|
||||
BLT_ERROR("The assertion '{}' has failed in file '{}:{:d}'", expression, path, line);
|
||||
if (msg != nullptr)
|
||||
BLT_ERROR(msg);
|
||||
BLT_ERROR("Stack Trace:");
|
||||
|
@ -175,8 +175,8 @@ namespace blt
|
|||
BLT_STACK_TRACE(50);
|
||||
#endif
|
||||
BLT_FATAL("----{BLT ABORT}----");
|
||||
BLT_FATAL("\tWhat: %s", what);
|
||||
BLT_FATAL("\tCalled from %s:%d", path, line);
|
||||
BLT_FATAL("\tWhat: {}", what);
|
||||
BLT_FATAL("\tCalled from {}:{:d}", path, line);
|
||||
#ifdef IS_GNU_BACKTRACE
|
||||
printStacktrace(messages, size, path, line);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace blt
|
|||
if (GetProcessTimes(GetCurrentProcess(),
|
||||
&starttime, &exittime, &kerneltime, &usertime) == 0)
|
||||
{
|
||||
BLT_WARN("Unable to get process resource usage, error: %d", GetLastError());
|
||||
BLT_WARN("Unable to get process resource usage, error: {:d}", GetLastError());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace blt
|
|||
#else
|
||||
if (getrusage(who, (struct rusage*) &usage) != 0)
|
||||
{
|
||||
BLT_ERROR("Failed to get rusage %d", errno);
|
||||
BLT_ERROR("Failed to get rusage {:d}", errno);
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -181,6 +181,7 @@ int main()
|
|||
BLT_WARN("This is a warning!");
|
||||
BLT_ERROR("This is an error!");
|
||||
BLT_FATAL("This is a fatal error!");
|
||||
BLT_TRACE("This is a pointer {:f}", &charCount);
|
||||
|
||||
/*std::cout << "\033[2J";
|
||||
constexpr int totalRows = 24;
|
||||
|
|
Loading…
Reference in New Issue