aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/utility/Logger.cpp
blob: 5e25c9849f4e7a7fd0399f7955182c1a0e7a2dd5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "Logger.hpp"

#include <iostream>

using namespace OpenVic;

void Logger::set_logger_funcs() {
   Logger::set_info_func([](std::string&& str) {
      std::cout << str;
   });
   Logger::set_warning_func([](std::string&& str) {
      std::cerr << str;
   });
   Logger::set_error_func([](std::string&& str) {
      std::cerr << str;
   });
}

char const* Logger::get_filename(char const* filepath, char const* default_path) {
   if (filepath == nullptr) {
      return default_path;
   }
   char const* last_slash = filepath;
   while (*filepath != '\0') {
      if (*filepath == '\\' || *filepath == '/') {
         last_slash = filepath + 1;
      }
      filepath++;
   }
   if (*last_slash == '\0') {
      return default_path;
   }
   return last_slash;
}