| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2020 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2016 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifdef HAVE_CONFIG_H |
| 9 | #include "config.h" |
| 10 | #endif |
| 11 | |
| 12 | #include "app/log.h" |
| 13 | |
| 14 | #include "app/app.h" |
| 15 | #include "app/resource_finder.h" |
| 16 | #include "base/log.h" |
| 17 | #include "fmt/format.h" |
| 18 | #include "ver/info.h" |
| 19 | |
| 20 | namespace app { |
| 21 | |
| 22 | LoggerModule::LoggerModule(bool createLogInDesktop) |
| 23 | { |
| 24 | app::ResourceFinder rf(false); |
| 25 | |
| 26 | if (createLogInDesktop) { |
| 27 | rf.includeDesktopDir(fmt::format("{}-v{}-DebugOutput.txt", |
| 28 | get_app_name(), |
| 29 | get_app_version()).c_str()); |
| 30 | } |
| 31 | else { |
| 32 | rf.includeUserDir(fmt::format("{}.log", get_app_name()).c_str()); |
| 33 | } |
| 34 | |
| 35 | auto filename = rf.defaultFilename(); |
| 36 | base::set_log_filename(filename.c_str()); |
| 37 | } |
| 38 | |
| 39 | LoggerModule::~LoggerModule() |
| 40 | { |
| 41 | LOG("LOG: Done\n"); |
| 42 | |
| 43 | // Close log file |
| 44 | base::set_log_filename(""); |
| 45 | } |
| 46 | |
| 47 | } // namespace app |
| 48 |