• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 18064138724

27 Sep 2025 04:20PM UTC coverage: 74.093% (+0.04%) from 74.05%
18064138724

push

github

Razakhel
[Utils/Logger] Added formatted logging overloads

- Formatted calls to logging functions and made use of std::format() in several other places

100 of 170 new or added lines in 36 files covered. (58.82%)

4 existing lines in 2 files now uncovered.

8334 of 11248 relevant lines covered (74.09%)

1757.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/src/RaZ/Script/LuaUtils.cpp
1
#include "RaZ/Script/LuaWrapper.hpp"
2
#include "RaZ/Utils/FilePath.hpp"
3
#include "RaZ/Utils/FileUtils.hpp"
4
#include "RaZ/Utils/Logger.hpp"
5
#include "RaZ/Utils/Ray.hpp"
6
#include "RaZ/Utils/Shape.hpp"
7
#include "RaZ/Utils/StrUtils.hpp"
8
#include "RaZ/Utils/TriggerSystem.hpp"
9
#include "RaZ/Utils/TriggerVolume.hpp"
10
#include "RaZ/Utils/TypeUtils.hpp"
11

12
#define SOL_ALL_SAFETIES_ON 1
13
#include "sol/sol.hpp"
14

15
namespace Raz {
16

17
using namespace TypeUtils;
18

19
void LuaWrapper::registerUtilsTypes() {
2✔
20
  sol::state& state = getState();
2✔
21

22
  {
23
    sol::usertype<FilePath> filePath = state.new_usertype<FilePath>("FilePath",
24
                                                                    sol::constructors<FilePath(),
×
25
                                                                                      FilePath(const char*),
26
                                                                                      FilePath(const std::string&)>());
2✔
27
    filePath["isEmpty"]           = &FilePath::isEmpty;
2✔
28
    filePath["recoverPathToFile"] = PickOverload<>(&FilePath::recoverPathToFile);
2✔
29
    filePath["recoverFileName"]   = sol::overload([] (const FilePath& f) { return f.recoverFileName(); },
3✔
30
                                                  PickOverload<bool>(&FilePath::recoverFileName));
4✔
31
    filePath["recoverExtension"]  = PickOverload<>(&FilePath::recoverExtension);
2✔
32
    filePath["toUtf8"]            = &FilePath::toUtf8;
2✔
33
    filePath.set_function(sol::meta_function::concatenation, sol::overload(PickOverload<const char*>(&FilePath::operator+),
2✔
34
                                                                           PickOverload<const std::string&>(&FilePath::operator+),
2✔
35
                                                                           PickOverload<const FilePath&>(&FilePath::operator+),
2✔
36
                                                                           [] (const char* s, const FilePath& p) { return s + p; },
1✔
37
                                                                           [] (const std::string& s, const FilePath& p) { return s + p; }));
×
38
  }
2✔
39

40
  {
41
    sol::table fileUtils          = state["FileUtils"].get_or_create<sol::table>();
2✔
42
    fileUtils["isReadable"]       = &FileUtils::isReadable;
2✔
43
    fileUtils["readFileToArray"]  = &FileUtils::readFileToArray;
2✔
44
    fileUtils["readFileToString"] = &FileUtils::readFileToString;
2✔
45
  }
2✔
46

47
  {
48
    sol::table logger              = state["Logger"].get_or_create<sol::table>();
2✔
49
    logger["setLoggingLevel"]      = &Logger::setLoggingLevel;
2✔
50
    logger["setLoggingFunction"]   = &Logger::setLoggingFunction;
2✔
51
    logger["resetLoggingFunction"] = &Logger::resetLoggingFunction;
2✔
52
    logger["error"]                = static_cast<void(*)(const std::string&)>(&Logger::error);
2✔
53
    logger["warn"]                 = static_cast<void(*)(const std::string&)>(&Logger::warn);
2✔
54
    logger["info"]                 = static_cast<void(*)(const std::string&)>(&Logger::info);
2✔
NEW
55
    logger["debug"]                = sol::overload(static_cast<void(*)(const std::string&)>(&Logger::debug),
×
56
                                                   static_cast<void(*)(std::format_string<>)>(&Logger::debug));
2✔
57

58
    state.new_enum<LoggingLevel>("LoggingLevel", {
2✔
59
      { "NONE",    LoggingLevel::NONE },
2✔
60
      { "ERROR",   LoggingLevel::ERROR },
2✔
61
      { "WARNING", LoggingLevel::WARNING },
2✔
62
      { "INFO",    LoggingLevel::INFO },
2✔
63
      { "DEBUG",   LoggingLevel::DEBUG },
2✔
64
      { "ALL",     LoggingLevel::ALL }
2✔
65
    });
66
  }
2✔
67

68
  {
69
    {
70
      sol::usertype<RayHit> rayHit = state.new_usertype<RayHit>("RayHit",
71
                                                                sol::constructors<RayHit()>());
2✔
72
      rayHit["position"] = &RayHit::position;
2✔
73
      rayHit["normal"]   = &RayHit::normal;
2✔
74
      rayHit["distance"] = &RayHit::distance;
2✔
75
    }
2✔
76

77
    {
78
      sol::usertype<Ray> ray = state.new_usertype<Ray>("Ray",
79
                                                       sol::constructors<Ray(const Vec3f&, const Vec3f&)>());
2✔
80
      ray["getOrigin"]           = &Ray::getOrigin;
2✔
81
      ray["getDirection"]        = &Ray::getDirection;
2✔
82
      ray["getInverseDirection"] = &Ray::getInverseDirection;
2✔
83
      ray["intersects"]          = sol::overload([] (const Ray& r, const Vec3f& p) { r.intersects(p); },
3✔
84
                                                 PickOverload<const Vec3f&, RayHit*>(&Ray::intersects),
2✔
85
                                                 [] (const Ray& r, const AABB& s) { r.intersects(s); },
1✔
86
                                                 PickOverload<const AABB&, RayHit*>(&Ray::intersects),
2✔
87
                                                 //[] (const Ray& r, const Line& s) { r.intersects(s); },
88
                                                 //PickOverload<const Line&, RayHit*>(&Ray::intersects),
89
                                                 //[] (const Ray& r, const OBB& s) { r.intersects(s); },
90
                                                 //PickOverload<const OBB&, RayHit*>(&Ray::intersects),
91
                                                 [] (const Ray& r, const Plane& s) { r.intersects(s); },
1✔
92
                                                 PickOverload<const Plane&, RayHit*>(&Ray::intersects),
2✔
93
                                                 //[] (const Ray& r, const Quad& s) { r.intersects(s); },
94
                                                 //PickOverload<const Quad&, RayHit*>(&Ray::intersects),
95
                                                 [] (const Ray& r, const Sphere& s) { r.intersects(s); },
1✔
96
                                                 PickOverload<const Sphere&, RayHit*>(&Ray::intersects),
2✔
97
                                                 [] (const Ray& r, const Triangle& s) { r.intersects(s); },
1✔
98
                                                 PickOverload<const Triangle&, RayHit*>(&Ray::intersects));
4✔
99
      ray["computeProjection"]   = &Ray::computeProjection;
2✔
100
    }
2✔
101
  }
102

103
  {
104
    sol::table strUtils         = state["StrUtils"].get_or_create<sol::table>();
2✔
105
    strUtils["startsWith"]      = PickOverload<const std::string&, const std::string&>(&StrUtils::startsWith);
2✔
106
    strUtils["endsWith"]        = PickOverload<const std::string&, const std::string&>(&StrUtils::endsWith);
2✔
107
    strUtils["toLowercaseCopy"] = PickOverload<std::string>(&StrUtils::toLowercaseCopy);
2✔
108
    strUtils["toUppercaseCopy"] = PickOverload<std::string>(&StrUtils::toUppercaseCopy);
2✔
109
    strUtils["trimLeftCopy"]    = PickOverload<std::string>(&StrUtils::trimLeftCopy);
2✔
110
    strUtils["trimRightCopy"]   = PickOverload<std::string>(&StrUtils::trimRightCopy);
2✔
111
    strUtils["trimCopy"]        = PickOverload<std::string>(&StrUtils::trimCopy);
2✔
112
    strUtils["split"]           = &StrUtils::split<std::string>;
2✔
113
  }
2✔
114

115
  {
116
    state.new_usertype<Triggerer>("Triggerer", sol::constructors<Triggerer()>());
2✔
117
  }
118

119
  {
120
    state.new_usertype<TriggerSystem>("TriggerSystem", sol::constructors<TriggerSystem()>());
2✔
121
  }
122

123
  {
124
    sol::usertype<TriggerVolume> triggerVolume = state.new_usertype<TriggerVolume>("TriggerVolume",
125
                                                                                   sol::constructors<TriggerVolume(const AABB&),
×
126
                                                                                                     TriggerVolume(const OBB&),
127
                                                                                                     TriggerVolume(const Sphere&)>());
2✔
128
    triggerVolume["setEnterAction"]   = &TriggerVolume::setEnterAction;
2✔
129
    triggerVolume["setStayAction"]    = &TriggerVolume::setStayAction;
2✔
130
    triggerVolume["setLeaveAction"]   = &TriggerVolume::setLeaveAction;
2✔
131
    triggerVolume["enable"]           = sol::overload([] (TriggerVolume& v) { v.enable(); },
3✔
132
                                                      PickOverload<bool>(&TriggerVolume::enable));
4✔
133
    triggerVolume["disable"]          = &TriggerVolume::disable;
2✔
134
    triggerVolume["resetEnterAction"] = &TriggerVolume::resetEnterAction;
2✔
135
    triggerVolume["resetStayAction"]  = &TriggerVolume::resetStayAction;
2✔
136
    triggerVolume["resetLeaveAction"] = &TriggerVolume::resetLeaveAction;
2✔
137
  }
2✔
138
}
2✔
139

140
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc