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

Razakhel / RaZ / 18062694977

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

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

71.79
/src/RaZ/Script/LuaEnvironment.cpp
1
#include "RaZ/Entity.hpp"
2
#include "RaZ/Script/LuaEnvironment.hpp"
3
#include "RaZ/Script/LuaWrapper.hpp"
4
#include "RaZ/Utils/FilePath.hpp"
5
#include "RaZ/Utils/Logger.hpp"
6

7
#define SOL_ALL_SAFETIES_ON 1
8
#define SOL_PRINT_ERRORS 0
9
#include "sol/sol.hpp"
10

11
#include "tracy/Tracy.hpp"
12

13
namespace Raz {
14

15
LuaEnvironment::LuaEnvironment()
12✔
16
  : m_environment{ std::make_unique<sol::environment>(LuaWrapper::getState(), sol::create, LuaWrapper::getState().globals()) } {}
12✔
17

18
bool LuaEnvironment::execute(const std::string& code) const {
21✔
19
  ZoneScopedN("LuaEnvironment::execute");
20

21
  if (code.empty())
21✔
22
    return false;
1✔
23

24
  Logger::debug("[LuaEnvironment] Executing code...");
20✔
25

26
  try {
27
    LuaWrapper::getState().script(code, *m_environment);
20✔
28
  } catch (const sol::error& err) {
1✔
29
    Logger::error("[LuaEnvironment] Error executing code: '{}'", err.what());
1✔
30
    return false;
1✔
31
  }
1✔
32

33
  Logger::debug("[LuaEnvironment] Executed code");
19✔
34

35
  return true;
19✔
36
}
37

38
bool LuaEnvironment::executeFromFile(const FilePath& filePath) const {
×
39
  ZoneScopedN("LuaEnvironment::executeFromFile");
40
  ZoneTextF("Path: %s", filePath.toUtf8().c_str());
41

42
  if (filePath.isEmpty())
×
43
    return false;
×
44

NEW
45
  Logger::debug("[LuaEnvironment] Executing code from file ('{}')...", filePath);
×
46

47
  try {
48
    LuaWrapper::getState().script_file(filePath.toUtf8(), *m_environment);
×
49
  } catch (const sol::error& err) {
×
NEW
50
    Logger::error("[LuaEnvironment] Error executing code from file: '{}'", err.what());
×
51
    return false;
×
52
  }
×
53

54
  Logger::debug("[LuaEnvironment] Executed code from file");
×
55

56
  return true;
×
57
}
58

59
bool LuaEnvironment::exists(const char* name) const {
33✔
60
  return get(name).valid();
33✔
61
}
62

63
void LuaEnvironment::clear() {
21✔
64
  Logger::debug("[LuaEnvironment] Clearing environment...");
21✔
65
  m_environment->clear();
21✔
66
  Logger::debug("[LuaEnvironment] Cleared environment");
21✔
67
}
21✔
68

69
LuaEnvironment::~LuaEnvironment() = default;
12✔
70

71
void LuaEnvironment::registerEntity(const Entity& entity, const std::string& name) {
7✔
72
  Logger::debug("[LuaEnvironment] Registering entity (ID: {}) as '{}'...", entity.getId(), name);
7✔
73
  m_environment->operator[](name) = &entity;
7✔
74
  Logger::debug("[LuaEnvironment] Registered entity");
7✔
75
}
7✔
76

77
sol::reference LuaEnvironment::get(const char* name) const {
86✔
78
  return m_environment->operator[](name);
86✔
79
}
80

81
} // 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