[Development] QLog ( Work on qDebug and friends)
Lincoln Ramsay
lincoln.ramsay at nokia.com
Wed Feb 1 02:20:17 CET 2012
On 01/31/2012 03:32 PM, ext wolfgang.beck at nokia.com wrote:
> 1. Logging in a file:
> 2. Enable or disable logging without recompiling your project.
I would like to comment on number 1.
I think it's important that a reasonably-unique default config file
exists for each application. Why? Because without it, number 2 doesn't
actually work.
I think a file name should be created based on the platform, and
QCoreApplication properties like organizationName and applicationName
(similar to QSettings).
On a Mac, you might end up with ~/Library/Application
Support/OrganizationName/ApplicationName/Logging.txt
On Windows, you might end up with %HOMEDRIVE%%HOMEPATH%\App
Data\OrganizationName\ApplicationName\Logging.txt
On Linux, you might end up with
~/.config/OrganizationName/ApplicationName/Logging.txt
If you don't supply the organization or app names then perhaps a
fallback to he binary name.
This then, is the "default" logging config file and we can document it
reliably for each platform.
I think it's probably a good idea to leave in the setConfigFile method
but I'd call it setDefaultConfigFile. This overrides the generated
default and is useful for cases where you want multiple apps to pick up
the same logging config file. It also allows app developers to keep the
logging file with their other config/data if that location differs from
where we used.
Finally, to give the user control, I think we need an environment
variable that overrides both of the above. Say, QLOG_CONFIG_FILE. By
setting this environment variable, the user can be certain that their
logging config file will be used. It can also be used to cause multiple
apps to use the same logging config file. Finally, it ensures the user
can enable logging even if they don't have permission to write to the
default config file.
In summary:
1) Generated default logging config file (for sanity).
2) QLog::setDefaultConfigFile for application writers.
3) QLOG_CONFIG_FILE for users.
Oh, and since there was no link to the change in your email, here it is:
http://codereview.qt-project.org/#change,13226
--
Lincoln Ramsay - Senior Software Engineer
Qt Development Frameworks, Nokia - http://qt.nokia.com/
More information about the Development
mailing list