~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/logger.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author: Julien Bonjean <julien.bonjean@savoirfairelinux.com>
4
4
 *
5
5
 *  This program is free software; you can redistribute it and/or modify
31
31
#ifndef LOGGER_H_
32
32
#define LOGGER_H_
33
33
 
 
34
#include <pthread.h>
 
35
#ifdef __ANDROID__
 
36
#include <cstring>
 
37
#include <android/log.h>
 
38
#else
34
39
#include <syslog.h>
35
 
#include <pthread.h>
 
40
#endif
36
41
 
37
42
namespace Logger {
38
43
void log(const int, const char*, ...);
40
45
void setConsoleLog(bool);
41
46
void setDebugMode(bool);
42
47
bool getDebugMode();
 
48
void strErr();
43
49
};
44
50
 
45
 
#define LOGGER(M, LEVEL, ...) Logger::log(LEVEL, "%s:%d:tid %lu:\t" M, __FILE__, \
46
 
                                          __LINE__, pthread_self() & 0xffff, ##__VA_ARGS__)
47
 
 
 
51
#define LOG_FORMAT(M, ...) "%s:%d:0x%x: " M, FILE_NAME, __LINE__, (unsigned long) pthread_self() & 0xffff, ##__VA_ARGS__
 
52
 
 
53
#ifndef __ANDROID__
 
54
 
 
55
#define FILE_NAME __FILE__
48
56
#define ERROR(M, ...)   LOGGER(M, LOG_ERR, ##__VA_ARGS__)
49
57
#define WARN(M, ...)    LOGGER(M, LOG_WARNING, ##__VA_ARGS__)
50
58
#define INFO(M, ...)    LOGGER(M, LOG_INFO, ##__VA_ARGS__)
51
59
#define DEBUG(M, ...)   LOGGER(M, LOG_DEBUG, ##__VA_ARGS__)
 
60
#define LOGGER(M, LEVEL, ...) Logger::log(LEVEL, LOG_FORMAT(M, ##__VA_ARGS__))
 
61
 
 
62
#else /* ANDROID */
 
63
 
 
64
#ifndef APP_NAME
 
65
#define APP_NAME "libsflphone"
 
66
#endif
 
67
 
 
68
// Avoid printing whole path on android
 
69
#define FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
 
70
 
 
71
#define ERROR(M, ...)   LOGGER(M, ANDROID_LOG_ERROR, ##__VA_ARGS__)
 
72
#define WARN(M, ...)    LOGGER(M, ANDROID_LOG_WARN, ##__VA_ARGS__)
 
73
#define INFO(M, ...)    LOGGER(M, ANDROID_LOG_INFO, ##__VA_ARGS__)
 
74
#define DEBUG(M, ...)   LOGGER(M, ANDROID_LOG_DEBUG, ##__VA_ARGS__)
 
75
#define LOGGER(M, LEVEL, ...) __android_log_print(LEVEL, APP_NAME, LOG_FORMAT(M, ##__VA_ARGS__))
 
76
#endif /* ANDROID */
52
77
 
53
78
#define BLACK "\033[22;30m"
54
79
#define RED "\033[22;31m"