Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
e679f436
Commit
e679f436
authored
2 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
logger: cleanup
Change-Id: I58028cad9b28b694ed271ebd1e9ebad7cd72f9fa
parent
14221db3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/logger.cpp
+13
-11
13 additions, 11 deletions
src/logger.cpp
src/logger.h
+5
-13
5 additions, 13 deletions
src/logger.h
with
18 additions
and
24 deletions
src/logger.cpp
+
13
−
11
View file @
e679f436
...
...
@@ -96,6 +96,11 @@
#define LOGFILE "jami"
namespace
jami
{
static
constexpr
auto
ENDL
=
'\n'
;
#ifndef __GLIBC__
static
const
char
*
check_error
(
int
result
,
char
*
buffer
)
{
...
...
@@ -116,9 +121,10 @@ check_error(char* result, char*)
{
return
result
;
}
#endif
void
strErr
(
void
)
strErr
()
{
#ifdef __GLIBC__
JAMI_ERR
(
"%m"
);
...
...
@@ -128,10 +134,6 @@ strErr(void)
#endif
}
namespace
jami
{
static
constexpr
auto
ENDL
=
'\n'
;
// extract the last component of a pathname (extract a filename from its dirname)
static
const
char
*
stripDirName
(
const
char
*
path
)
...
...
@@ -183,7 +185,7 @@ formatPrintfArgs(const char* format, va_list ap)
int
size
=
vsnprintf
(
ret
.
data
(),
ret
.
size
(),
format
,
ap
);
/* Not enough space? Well try again. */
if
(
size
>=
ret
.
size
())
{
if
(
(
size_t
)
size
>=
ret
.
size
())
{
ret
.
resize
(
size
+
1
);
vsnprintf
((
char
*
)
ret
.
data
(),
ret
.
size
(),
format
,
cp
);
}
...
...
@@ -200,17 +202,17 @@ struct Logger::Msg
Msg
()
=
delete
;
Msg
(
int
level
,
const
char
*
file
,
int
line
,
bool
linefeed
,
std
::
string
&&
message
)
:
header_
(
contextHeader
(
file
,
line
))
:
payload_
(
std
::
move
(
message
))
,
header_
(
contextHeader
(
file
,
line
))
,
level_
(
level
)
,
linefeed_
(
linefeed
)
,
payload_
(
std
::
move
(
message
))
{}
Msg
(
int
level
,
const
char
*
file
,
int
line
,
bool
linefeed
,
const
char
*
fmt
,
va_list
ap
)
:
header_
(
contextHeader
(
file
,
line
))
:
payload_
(
formatPrintfArgs
(
fmt
,
ap
))
,
header_
(
contextHeader
(
file
,
line
))
,
level_
(
level
)
,
linefeed_
(
linefeed
)
,
payload_
(
formatPrintfArgs
(
fmt
,
ap
))
{}
Msg
(
Msg
&&
other
)
...
...
@@ -394,7 +396,7 @@ public:
#ifdef __ANDROID__
__android_log_print
(
msg
.
level_
,
APP_NAME
,
"%s%s"
,
msg
.
header_
.
c_str
(),
msg
.
payload_
.
c_str
());
#else
::
syslog
(
msg
.
level_
,
"%s"
,
msg
.
payload_
.
c_str
());
::
syslog
(
msg
.
level_
,
"%
.*
s"
,
(
int
)
msg
.
payload_
.
size
(),
msg
.
payload_
.
data
());
#endif
}
};
...
...
This diff is collapsed.
Click to expand it.
src/logger.h
+
5
−
13
View file @
e679f436
...
...
@@ -35,19 +35,6 @@
#include
<string>
#include
"string_utils.h"
// to_string
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* Thread-safe function to print the stringified contents of errno
*/
void
strErr
();
#ifdef __cplusplus
}
#endif
#ifdef __ANDROID__
#include
<android/log.h>
...
...
@@ -80,6 +67,11 @@ void strErr();
namespace
jami
{
/**
* Thread-safe function to print the stringified contents of errno
*/
void
strErr
();
///
/// Level-driven logging class that support printf and C++ stream logging fashions.
///
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment