Browse Source

mconnect: move logging to separate file

bboozzoo/self-announce
Maciek Borzecki 8 years ago
parent
commit
717749a2c0
4 changed files with 48 additions and 23 deletions
  1. +1
    -1
      src/mconnect/application.vala
  2. +1
    -1
      src/mconnect/devicechannel.vala
  3. +46
    -0
      src/mconnect/logging.vala
  4. +0
    -21
      src/mconnect/utils.vala

+ 1
- 1
src/mconnect/application.vala View File

@ -56,7 +56,7 @@ namespace Mconn {
Environment.set_variable("G_MESSAGES_DEBUG", "all", false);
if (log_debug_verbose == true)
enable_vdebug();
Logging.enable_vdebug();
core = Core.instance();
if (core == null)


+ 1
- 1
src/mconnect/devicechannel.vala View File

@ -161,7 +161,7 @@ class DeviceChannel : Object {
this.peer_certificate = peer_cert;
if (expected_peer != null) {
if (DebugLog.Verbose) {
if (Logging.VERBOSE) {
vdebug("verify certificate, expecting: %s, got: %s",
expected_peer.certificate_pem,
peer_cert.certificate_pem);


+ 46
- 0
src/mconnect/logging.vala View File

@ -0,0 +1,46 @@
/**
* 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
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* AUTHORS
* Maciek Borzecki <maciek.borzecki (at] gmail.com>
*/
namespace Logging {
public bool VERBOSE = false;
/**
* enable_vdebug:
*
* Enable verbose debug logging
*/
void enable_vdebug() {
VERBOSE = true;
}
}
/**
* vdebug:
* @format: format string
*
* Same as debug() but looks at verbose debug flag
*/
void vdebug(string format, ...) {
if (Logging.VERBOSE == true) {
var l = va_list();
logv(null, LogLevelFlags.LEVEL_DEBUG, format, l);
}
}

+ 0
- 21
src/mconnect/utils.vala View File

@ -19,27 +19,6 @@
*/
using Posix;
namespace DebugLog{
public bool Verbose = false;
}
void enable_vdebug() {
DebugLog.Verbose = true;
}
/**
* vdebug:
* @format: format string
*
* Same as debug() but looks at verbose debug flag
*/
void vdebug(string format, ...) {
if (DebugLog.Verbose == true) {
var l = va_list();
logv(null, LogLevelFlags.LEVEL_DEBUG, format, l);
}
}
/**
* make_unique_device_string:
* @id: device ID


Loading…
Cancel
Save