Skip to content

Commit

Permalink
fix(logs): change log location, should fix(#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
alphagocc committed Aug 7, 2023
1 parent 12f068d commit 599e9d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion makespec/BUILDVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
250
251
16 changes: 11 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "base/LemonBase.hpp"
#include "base/LemonBaseApplication.hpp"
#include "base/LemonLog.hpp"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
//
#include <QApplication>
#include <QPixmap>
Expand All @@ -25,8 +25,12 @@
void initLogger() {
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
console_sink->set_level(spdlog::level::warn);

auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("log.txt", true);
QDir logDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QDir::separator() +
"logs");
logDir.mkpath(".");
// New file at 4:00, retain last 30 days logs
auto file_sink = std::make_shared<spdlog::sinks::daily_file_sink_mt>(
(logDir.path() + QDir::separator() + "lemonlime-log.txt").toStdString(), 4, 0, false, 30);
file_sink->set_level(spdlog::level::trace);
Lemon::base::logger =
std::make_shared<spdlog::logger>(spdlog::logger("lemonlime", {console_sink, file_sink}));
Expand All @@ -35,15 +39,17 @@ void initLogger() {

int main(int argc, char *argv[]) {

initLogger();

#ifndef LEMON_QT6
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // High DPI supported
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
QApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); // Qt 6 compatibility
#endif

QCoreApplication::setApplicationName("Lemonlime");

initLogger();

Lemon::LemonBaseApplication app(argc, argv);

app.Initialize();
Expand Down

0 comments on commit 599e9d8

Please sign in to comment.