Skip to content

Commit

Permalink
[fix] fixed dot in folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Sygmei committed Jul 4, 2022
1 parent 3582dbc commit 26b3d6b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
7 changes: 2 additions & 5 deletions include/logger.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <spdlog/logger.h>

namespace obe::tiled_integration
{
extern std::shared_ptr<spdlog::logger> logger;
void init_logger();
}
extern std::shared_ptr<spdlog::logger> logger;
void init_logger();
37 changes: 18 additions & 19 deletions src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@
#include <spdlog/sinks/ansicolor_sink.h>
#endif

namespace obe::tiled_integration

std::shared_ptr<spdlog::logger> logger;

void init_logger()
{
std::shared_ptr<spdlog::logger> logger;

void init_logger()
{
auto dist_sink = std::make_shared<spdlog::sinks::dist_sink_st>();

const auto sink1 = std::make_shared<spdlog::sinks::stdout_color_sink_st>();
const auto sink2
= std::make_shared<spdlog::sinks::basic_file_sink_st>("debug.log");

dist_sink->add_sink(sink1);
dist_sink->add_sink(sink2);
logger = std::make_shared<spdlog::logger>("Log", dist_sink);
logger->set_pattern("[%H:%M:%S.%e]<%^%l%$> : %v");
logger->set_level(spdlog::level::info);
logger->flush_on(spdlog::level::info);
logger->info("Logger initialized");
}
auto dist_sink = std::make_shared<spdlog::sinks::dist_sink_st>();

const auto sink1 = std::make_shared<spdlog::sinks::stdout_color_sink_st>();
const auto sink2
= std::make_shared<spdlog::sinks::basic_file_sink_st>("debug.log");

dist_sink->add_sink(sink1);
dist_sink->add_sink(sink2);
logger = std::make_shared<spdlog::logger>("Log", dist_sink);
logger->set_pattern("[%H:%M:%S.%e]<%^%l%$> : %v");
logger->set_level(spdlog::level::debug);
logger->flush_on(spdlog::level::info);
logger->info("Logger initialized");
}

9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ std::string normalize_path(std::string path)
nlohmann::json::object_t load_tiled_map(const std::string& filepath)
{
std::ifstream input_file(filepath);
std::ifstream ifs(filepath);
std::string content(
(std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
nlohmann::json tiled_json;
input_file >> tiled_json;

Expand All @@ -36,9 +39,10 @@ nlohmann::json::object_t load_tiled_map(const std::string& filepath)
nlohmann::json::object_t load_tiled_tileset(const std::string& directory, const std::string& filename)
{
std::string json_filepath = std::filesystem::canonical(std::filesystem::path(directory) / filename).string();
const auto first_dot = json_filepath.find('.');
const auto first_dot = json_filepath.find_last_of('.');
json_filepath = std::string(json_filepath.begin(), json_filepath.begin() + first_dot);
json_filepath += ".json";
logger->debug(" Loading tileset at path {}", json_filepath);
std::ifstream input_file(json_filepath);
nlohmann::json tileset_json;
input_file >> tileset_json;
Expand Down Expand Up @@ -487,8 +491,6 @@ void run(const TiledIntegrationArgs& args)

TiledIntegrationArgs parse_args(int argc, char** argv)
{
using namespace obe::tiled_integration;

TiledIntegrationArgs args;

const lyra::cli cli = lyra::arg(args.input_file, "input_file").required(true)
Expand Down Expand Up @@ -519,7 +521,6 @@ TiledIntegrationArgs parse_args(int argc, char** argv)

int main(int argc, char** argv)
{
using namespace obe::tiled_integration;
init_logger();

const TiledIntegrationArgs args = parse_args(argc, argv);
Expand Down

0 comments on commit 26b3d6b

Please sign in to comment.