Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
d24be527
Commit
d24be527
authored
Jan 23, 2018
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Logger): use C++ API now, remove link to lib linphone C
parent
52ac3d09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
39 deletions
+62
-39
CMakeLists.txt
CMakeLists.txt
+2
-4
Logger.cpp
src/app/logger/Logger.cpp
+60
-35
No files found.
CMakeLists.txt
View file @
d24be527
...
@@ -91,12 +91,10 @@ endif ()
...
@@ -91,12 +91,10 @@ endif ()
set
(
QT5_PACKAGES_OPTIONAL TextToSpeech
)
set
(
QT5_PACKAGES_OPTIONAL TextToSpeech
)
if
(
LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS
)
if
(
LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS
)
include
(
"
${
EP_linphone_CONFIG_DIR
}
/LinphoneConfig.cmake"
)
include
(
"
${
EP_linphone_CONFIG_DIR
}
/wrappers/cpp/LinphoneCxxConfig.cmake"
)
include
(
"
${
EP_linphone_CONFIG_DIR
}
/wrappers/cpp/LinphoneCxxConfig.cmake"
)
include
(
"
${
EP_bctoolbox_CONFIG_DIR
}
/BcToolboxConfig.cmake"
)
include
(
"
${
EP_bctoolbox_CONFIG_DIR
}
/BcToolboxConfig.cmake"
)
include
(
"
${
EP_belcard_CONFIG_DIR
}
/BelcardConfig.cmake"
)
include
(
"
${
EP_belcard_CONFIG_DIR
}
/BelcardConfig.cmake"
)
else
()
else
()
find_package
(
Linphone REQUIRED
)
find_package
(
LinphoneCxx REQUIRED
)
find_package
(
LinphoneCxx REQUIRED
)
find_package
(
BcToolbox REQUIRED
)
find_package
(
BcToolbox REQUIRED
)
find_package
(
Belcard REQUIRED
)
find_package
(
Belcard REQUIRED
)
...
@@ -359,8 +357,8 @@ endif ()
...
@@ -359,8 +357,8 @@ endif ()
set_target_properties
(
${
TARGET_NAME
}
PROPERTIES OUTPUT_NAME
"
${
EXECUTABLE_NAME
}
"
)
set_target_properties
(
${
TARGET_NAME
}
PROPERTIES OUTPUT_NAME
"
${
EXECUTABLE_NAME
}
"
)
set_target_properties
(
${
TESTER_TARGET_NAME
}
PROPERTIES OUTPUT_NAME
"
${
TESTER_EXECUTABLE_NAME
}
"
)
set_target_properties
(
${
TESTER_TARGET_NAME
}
PROPERTIES OUTPUT_NAME
"
${
TESTER_EXECUTABLE_NAME
}
"
)
set
(
INCLUDED_DIRECTORIES
"
${
LINPHONECXX_INCLUDE_DIRS
}
"
"
${
LINPHONE_INCLUDE_DIRS
}
"
"
${
BELCARD_INCLUDE_DIRS
}
"
"
${
BCTOOLBOX_INCLUDE_DIRS
}
"
)
set
(
INCLUDED_DIRECTORIES
"
${
LINPHONECXX_INCLUDE_DIRS
}
"
"
${
BELCARD_INCLUDE_DIRS
}
"
"
${
BCTOOLBOX_INCLUDE_DIRS
}
"
)
set
(
LIBRARIES
${
BCTOOLBOX_CORE_LIBRARIES
}
${
BELCARD_LIBRARIES
}
${
LINPHONE
_LIBRARIES
}
${
LINPHONE
CXX_LIBRARIES
}
)
set
(
LIBRARIES
${
BCTOOLBOX_CORE_LIBRARIES
}
${
BELCARD_LIBRARIES
}
${
LINPHONECXX_LIBRARIES
}
)
foreach
(
package
${
QT5_PACKAGES
}
)
foreach
(
package
${
QT5_PACKAGES
}
)
list
(
APPEND INCLUDED_DIRECTORIES
"
${
Qt5
${
package
}
_INCLUDE_DIRS
}
"
)
list
(
APPEND INCLUDED_DIRECTORIES
"
${
Qt5
${
package
}
_INCLUDE_DIRS
}
"
)
...
...
src/app/logger/Logger.cpp
View file @
d24be527
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
*/
*/
#include <bctoolbox/logging.h>
#include <bctoolbox/logging.h>
#include <linphone/linphonecore.h>
#include <QDateTime>
#include <QDateTime>
#include <QThread>
#include <QThread>
...
@@ -68,34 +67,56 @@ static inline QByteArray getFormattedCurrentTime () {
...
@@ -68,34 +67,56 @@ static inline QByteArray getFormattedCurrentTime () {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
static
void
linphoneLog
(
const
char
*
domain
,
OrtpLogLevel
type
,
const
char
*
fmt
,
va_list
args
)
{
class
LinphoneLogger
:
public
linphone
::
LoggingServiceListener
{
const
char
*
format
;
public:
LinphoneLogger
(
const
Logger
*
logger
)
:
mLogger
(
logger
)
{}
if
(
type
==
ORTP_DEBUG
)
format
=
GREEN
"[%s][Debug]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
private:
else
if
(
type
==
ORTP_TRACE
)
void
onLogMessageWritten
(
format
=
BLUE
"[%s][Trace]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
const
shared_ptr
<
linphone
::
LoggingService
>
&
,
else
if
(
type
==
ORTP_MESSAGE
)
const
string
&
domain
,
format
=
BLUE
"[%s][Info]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
linphone
::
LogLevel
level
,
else
if
(
type
==
ORTP_WARNING
)
const
string
&
message
format
=
RED
"[%s][Warning]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
)
override
{
else
if
(
type
==
ORTP_ERROR
)
if
(
!
mLogger
->
isVerbose
())
format
=
RED
"[%s][Error]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
return
;
else
if
(
type
==
ORTP_FATAL
)
format
=
RED
"[%s][Fatal]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
const
char
*
format
;
else
switch
(
level
)
{
return
;
case
linphone
:
:
LogLevel
::
LogLevelDebug
:
format
=
GREEN
"[%s][Debug]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
QByteArray
dateTime
=
::
getFormattedCurrentTime
();
break
;
char
*
msg
=
bctbx_strdup_vprintf
(
fmt
,
args
);
case
linphone
:
:
LogLevel
::
LogLevelTrace
:
format
=
BLUE
"[%s][Trace]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelMessage
:
format
=
BLUE
"[%s][Info]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelWarning
:
format
=
RED
"[%s][Warning]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelError
:
format
=
RED
"[%s][Error]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelFatal
:
format
=
RED
"[%s][Fatal]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
}
fprintf
(
stderr
,
format
,
dateTime
.
constData
(),
domain
?
domain
:
"linphone"
,
msg
);
fprintf
(
stderr
,
format
,
::
getFormattedCurrentTime
().
constData
(),
domain
.
empty
()
?
domain
.
c_str
()
:
"linphone"
,
message
.
c_str
()
);
bctbx_free
(
msg
);
if
(
level
==
linphone
::
LogLevel
::
LogLevelFatal
)
terminate
();
};
if
(
type
==
ORTP_FATAL
)
const
Logger
*
mLogger
;
abort
();
};
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -150,13 +171,17 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
...
@@ -150,13 +171,17 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
mMutex
.
unlock
();
mMutex
.
unlock
();
if
(
type
==
QtFatalMsg
)
if
(
type
==
QtFatalMsg
)
abort
();
terminate
();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
Logger
::
enable
(
bool
status
)
{
void
Logger
::
enable
(
bool
status
)
{
linphone_core_enable_log_collection
(
status
?
LinphoneLogCollectionEnabled
:
LinphoneLogCollectionDisabled
);
linphone
::
Core
::
enableLogCollection
(
status
?
linphone
::
LogCollectionStateEnabled
:
linphone
::
LogCollectionStateDisabled
);
}
}
void
Logger
::
init
(
const
shared_ptr
<
linphone
::
Config
>
&
config
)
{
void
Logger
::
init
(
const
shared_ptr
<
linphone
::
Config
>
&
config
)
{
...
@@ -170,14 +195,14 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
...
@@ -170,14 +195,14 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
qInstallMessageHandler
(
Logger
::
log
);
qInstallMessageHandler
(
Logger
::
log
);
linphone_core_set_log_level
(
ORTP_MESSAGE
);
{
linphone_core_set_log_handler
([](
const
char
*
domain
,
OrtpLogLevel
type
,
const
char
*
fmt
,
va_list
args
)
{
shared_ptr
<
linphone
::
LoggingService
>
loggingService
=
linphone
::
LoggingService
::
get
();
if
(
mInstance
->
isVerbose
())
loggingService
->
setLogLevel
(
linphone
::
LogLevel
::
LogLevelMessage
);
::
linphoneLog
(
domain
,
type
,
fmt
,
args
);
loggingService
->
setListener
(
make_shared
<
LinphoneLogger
>
(
mInstance
)
);
});
}
linphone_core_set_log_collection_path
(
::
Utils
::
appStringToCoreString
(
folder
).
c_str
());
linphone
::
Core
::
setLogCollectionPath
(
::
Utils
::
appStringToCoreString
(
folder
));
linphone
::
Core
::
setLogCollectionMaxFileSize
(
MAX_LOGS_COLLECTION_SIZE
);
linphone_core_set_log_collection_max_file_size
(
MAX_LOGS_COLLECTION_SIZE
);
mInstance
->
enable
(
SettingsModel
::
getLogsEnabled
(
config
));
mInstance
->
enable
(
SettingsModel
::
getLogsEnabled
(
config
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment