mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Create log in Desktop folder when --debug is used
This commit is contained in:
parent
b5d04525c0
commit
5fbb4e90d7
@ -109,7 +109,10 @@ public:
|
||||
// This is a raw pointer because we want to delete this explicitly.
|
||||
app::crash::DataRecovery* m_recovery;
|
||||
|
||||
Modules() : m_recovery(nullptr) { }
|
||||
Modules(bool createLogInDesktop)
|
||||
: m_loggerModule(createLogInDesktop)
|
||||
, m_recovery(nullptr) {
|
||||
}
|
||||
|
||||
app::crash::DataRecovery* recovery() {
|
||||
return m_recovery;
|
||||
@ -163,6 +166,7 @@ void App::initialize(const AppOptions& options)
|
||||
|
||||
m_coreModules = new CoreModules;
|
||||
|
||||
bool createLogInDesktop = false;
|
||||
switch (options.verboseLevel()) {
|
||||
case AppOptions::kNoVerbose:
|
||||
base::set_log_level(ERROR);
|
||||
@ -172,10 +176,11 @@ void App::initialize(const AppOptions& options)
|
||||
break;
|
||||
case AppOptions::kHighlyVerbose:
|
||||
base::set_log_level(VERBOSE);
|
||||
createLogInDesktop = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_modules = new Modules;
|
||||
m_modules = new Modules(createLogInDesktop);
|
||||
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
||||
m_brushes.reset(new AppBrushes);
|
||||
|
||||
|
@ -17,10 +17,15 @@
|
||||
|
||||
namespace app {
|
||||
|
||||
LoggerModule::LoggerModule()
|
||||
LoggerModule::LoggerModule(bool createLogInDesktop)
|
||||
{
|
||||
app::ResourceFinder rf(false);
|
||||
rf.includeUserDir("aseprite.log");
|
||||
|
||||
if (createLogInDesktop)
|
||||
rf.includeDesktopDir(PACKAGE "-v" VERSION "-DebugOutput.txt");
|
||||
else
|
||||
rf.includeUserDir("aseprite.log");
|
||||
|
||||
auto filename = rf.defaultFilename();
|
||||
base::set_log_filename(filename.c_str());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace app {
|
||||
|
||||
class LoggerModule {
|
||||
public:
|
||||
LoggerModule();
|
||||
LoggerModule(bool createLogInDesktop);
|
||||
~LoggerModule();
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -19,6 +19,11 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
namespace app {
|
||||
|
||||
ResourceFinder::ResourceFinder(bool log)
|
||||
@ -163,6 +168,41 @@ void ResourceFinder::includeUserDir(const char* filename)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ResourceFinder::includeDesktopDir(const char* filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
std::vector<wchar_t> buf(MAX_PATH);
|
||||
HRESULT hr = SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
|
||||
SHGFP_TYPE_DEFAULT, &buf[0]);
|
||||
if (hr == S_OK) {
|
||||
addPath(base::join_path(base::to_utf8(&buf[0]), filename));
|
||||
}
|
||||
else {
|
||||
includeHomeDir(filename);
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
// TODO get the desktop folder
|
||||
// $HOME/Desktop/filename
|
||||
includeHomeDir(base::join_path(std::string("Desktop"), filename).c_str());
|
||||
|
||||
#else
|
||||
|
||||
char* desktopDir = std::getenv("XDG_DESKTOP_DIR");
|
||||
if (desktopDir) {
|
||||
// $XDG_DESKTOP_DIR/filename
|
||||
addPath(base::join_path(desktopDir, filename));
|
||||
}
|
||||
else {
|
||||
// $HOME/Desktop/filename
|
||||
includeHomeDir(base::join_path(std::string("Desktop"), filename).c_str());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string ResourceFinder::getFirstOrCreateDefault()
|
||||
{
|
||||
std::string fn;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -51,6 +51,8 @@ namespace app {
|
||||
// - The filename will be in $HOME/.config/aseprite/
|
||||
void includeUserDir(const char* filename);
|
||||
|
||||
void includeDesktopDir(const char* filename);
|
||||
|
||||
// Returns the first file found or creates the whole directory
|
||||
// structure to create the file in its default location.
|
||||
std::string getFirstOrCreateDefault();
|
||||
|
Loading…
x
Reference in New Issue
Block a user