dept2 / cutelogger Goto Github PK
View Code? Open in Web Editor NEWLogger: simple, convinient and thread safe logger for Qt-based C++ apps
License: GNU Lesser General Public License v2.1
Logger: simple, convinient and thread safe logger for Qt-based C++ apps
License: GNU Lesser General Public License v2.1
Hello! I'd like to switch off escaping in my log. Is it possible?
When I log JSON fragment via LOG_TRACE()
to debug console, it contains ugly \" and \n elements.
Is the problem linked with noquote?
This is with Qt 4.8.4 and the latest CuteLogger revision.
#include "Logger.h"
#include <QtTest>
int main()
{
return 0;
}
Which gives this compiler error:
c:\qt\4.8.4\include\qttest\../../src/testlib/qtestbasicstreamer.h(50) : error C2270: 'loggerInstance' : modifiers not allowed on nonmember functions
c:\qt\4.8.4\include\qttest\../../src/testlib/qtestbasicstreamer.h(50) : error C2091: function returns function
The problem is the following line in Logger.h:
#define logger loggerInstance()
because qtestbasicstreamer.h has this:
const QTestLogger *logger() const;
As a workaround I've included QtTest before including Logger.h.
Error in RollingFileAppender.cpp line 55.
Qt does not support pattern "yyyy-ww" (such as ISO 8601). WeeklyRollover does not work.
Hello! I've tried to build console app with CuteLogger support.
I've added LOG_GLOBAL_CATEGORY macro under Q_OBJECT macro in QObject derived class declaration.
But MS VS 2019 has failed to compile it (error C3480).
a lambda capture must be a variable from an enclosing function scope
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c3480?view=msvc-170
Maybe you can update it to LGPL 3.0?
Good afternoon!
Thank you for a great module! I built it and connected to the project. Ubuntu. Everything is working.
// .pro file:
INCLUDEPATH += ./include/CuteLogger/include \
./libs/Logger
LIBS += -L libs/Logger -lLogger
Now I would like to try it on android device.
// .pro file:
android {
QT += androidextras
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
ANDROID_EXTRA_LIBS += $$PWD/android/libs/armeabi-v7a/libLogger.so
OTHER_FILES += android/AndroidManifest.xml
}
INCLUDEPATH += ./include/CuteLogger/include \
# ./libs/Logger
#LIBS += -L libs/Logger -lLogger
But the error occurs:
undefined reference to 'ConsoleAppender::ConsoleAppender()'
Please tell me how to connect the library to the application for android?
sorry, does the cutelogger has any readme?
Приветствую!
Надеюсь, меня поймут :)
Хороший логгер, спасибо за мое время. Однако, обнаружил тут мелкий глюк в деструкторе.
Logger::~Logger()
{
Q_D(Logger);
// Cleanup appenders
QMutexLocker appendersLocker(&d->appendersMutex);
foreach (AbstractAppender* appender, d->appenders)
delete appender;
// Cleanup device
delete d->logDevice;
delete d_ptr;
}
appendersLocker пытается разлокать мутекс по выходу из деструктора, но мутекс уже уничтожен, т.к. он сидит в d_ptr - падает, соответственно.
доп. область видимости спасла бы "отца русской демократии" :)
Hello, I want to print out all logging messages to a QListWidet. This is wrapped in a Qt Class which contains the function void widgetMessageList::addString(QString & message)
I would like to know if there is a method within cutelogger to connect to a slot, or use any Appender class to connect the logging string to my class.
Qt 6.1 Released now.
There are no rules in place in the make system to install the needed headers for use. The shared library get installed, but not headers.
Привет!
Прошу подсказать, возможно ли выполнить логгирование сразу нескольких запущенных экземпляров приложения а так же обеспечить своевременную чистку логов?
Мой код сейчас выглядит следующим образом:
void setupLogger(){
const QString LOG_DIR("log");
const QString &localDataPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
QDir().mkpath(localDataPath);
QDir(localDataPath).mkdir(LOG_DIR);
qDebug() << "Log dir:" << qUtf8Printable(localDataPath);
ConsoleAppender *consoleAppender = new ConsoleAppender;
consoleAppender->setFormat("[%{Type:-7}] %{message}\n");
RollingFileAppender *fileAppender = new RollingFileAppender(QStringLiteral("%1/%2/log").arg(localDataPath).arg(LOG_DIR));
fileAppender->setDatePattern(RollingFileAppender::DailyRollover);
fileAppender->setLogFilesLimit(100);
fileAppender->setFormat("[%{time}] [%{Type:-7}] %{message:-150} %{function:-40} %{line:-4}\n");
Logger::globalInstance()->registerAppender(consoleAppender);
Logger::globalInstance()->registerAppender(fileAppender);
}
Буду очень признателен за помощь
Hi! First of all, thanks for the such good project! Really useful.
In my opinion, the project lacks Readme file. I know, that user can use Doxygen to generate all documentation or read Logger.cpp file. But when you open project page and are trying to understand what this all about, how to use it and what features this project have, you see only bunch of the files and brief "Logger: simple, convinient and ...". Well, not so "user-friendly" =)
Thanks!
AbstractAppender.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) const akso::AbstractAppender::vftable'" (__imp_??_7AbstractAppender@akso@@6B@) AbstractStringAppender.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) const akso::AbstractStringAppender::
vftable'" (_imp??_7AbstractStringAppender@akso@@6b@)
ConsoleAppender.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) const akso::ConsoleAppender::`vftable'" (_imp??_7ConsoleAppender@akso@@6b@)
i want message which level>Info, if level < Info, it shoudn't log to consle/file, how to do this?
this is how Q_DISABLE_COPY being declared in qglobal.h:
/*
Some classes do not permit copies to be made of an object. These
classes contains a private copy constructor and assignment
operator to disable copying (the compiler gives an error message).
*/
#define Q_DISABLE_COPY(Class) \
Class(const Class &); \
Class &operator=(const Class &);
It seems the current license is LGPL-2.1-only, which means when mixing this library code with LGPLv3 code, the code from this library will be convey to GPLv3. If the code could relicense to LGPL-2.1-or-later, it won't be an issue.
Is there any plan to relicense or dual-license the library?
Thanks!
HI,
I'm using this library and it seems to work very good, but today I test the change of filename at runtime (basically I'm using a Qtimer to periodically check if the reference date is below at least 1 day from the current date. If yes, I'm calling setFileName to change the name of log file) and I got an exception every time I'm calling this function (I don't understand why, since the library has a Qmutex to protect the file name) more than 1 time.
Any suggestion or more information you need to understand what happens?
Thanks
Hello! There is a little warning in AbstractStringAppender.cpp:287:
'register' storage class specifier is deprecated and incompatible with C++1z [-Wdeprecated-register]
register char c = info.at(pos);
^~~~~~~~~
I would improve this, but don't know what is 'register' for.
clang 3.8.0
#include "Logger.h"
#include "RollingFileAppender.h"
RollingFileAppender* rollfile = new RollingFileAppender("test.log");
//roll every minute
rollfile->setDatePattern(RollingFileAppender::MinutelyRollover);
//3 logfile been retained
rollfile->setLogFilesLimit(3);
cuteLogger->registerCategoryAppender("categoryId",rollfile);
LOG_CERROR("categoryId")<<"roll every minute and retain 3 file";
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.