logging update

use QLoggingCategory now to provides improved logging
This commit is contained in:
Skycoder42
2016-02-08 12:57:35 +01:00
parent 04ce9f6a9c
commit c53a5dbcbe
8 changed files with 116 additions and 99 deletions
+8 -1
View File
@@ -4,7 +4,7 @@ A global shortcut/hotkey for Desktop Qt-Applications.
The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka shortcuts that work everywhere, independent of the application state. This means your application can be active, inactive, minimized or not visible at all and still receive the shortcuts.
## Status
**Still in development!!!** - But almost done. There are only some small details, like debug output, and documentation left. It's ready to be used.
**Still in development!!!** - But almost done. There are only some small details and documentation left. It's ready to be used.
## Features
- Works on Windows, Mac and X11
@@ -48,6 +48,13 @@ By running the example in `./HotkeyTest` you can test out the QHotkey class. The
- **Testings:** A list of selected hotkeys. Activate it and try out which ones work for you (*Hint:* Depending on OS and keyboard layout, it's very possible that a few don't work).
- **Threading:** Activate the checkbox to move 2 Hotkeys of the playground to seperate threads. It should work without a difference.
### Logging
By default, QHotkey prints some warning messages if something goes wrong (For example, a key that cannot be translated). All messages of QHotkey are grouped into the [`QLoggingCategory`](https://doc.qt.io/qt-5/qloggingcategory.html) "[QHotkey]". If you want to simply disable the logging, call the folling function somewhere in your code:
```cpp
QLoggingCategory::setFilterRules(QStringLiteral("[QHotkey].warning=false"));
```
This will turn all warnings of QHotkey of (It only uses warnings for now, thats why this is enough). For more information about all the things you can do with the logging categories, check the Qt-Documentation
## Thread saftey
The QHotkey class itself is reentrant - wich means you can create as many instances as required on any thread. This allows you to use the QHotkey on all threads. **But** you should never use the QHotkey instance on a thread that is different from the one the instance belongs to! Internally the system uses a singleton instance that handles the hotkey events and distributes them to the QHotkey instances. This internal class is completley threadsafe.