Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
436
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
8fa96a46
Commit
8fa96a46
authored
10 years ago
by
Rémi Denis-Courmont
Browse files
Options
Downloads
Patches
Plain Diff
logger: allow logger as a module
parent
add015be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/vlc_interface.h
+1
-13
1 addition, 13 deletions
include/vlc_interface.h
include/vlc_messages.h
+11
-0
11 additions, 0 deletions
include/vlc_messages.h
src/libvlc.c
+4
-4
4 additions, 4 deletions
src/libvlc.c
src/misc/messages.c
+66
-19
66 additions, 19 deletions
src/misc/messages.c
with
82 additions
and
36 deletions
include/vlc_interface.h
+
1
−
13
View file @
8fa96a46
...
...
@@ -106,22 +106,10 @@ static inline playlist_t *pl_Get( struct intf_thread_t *intf )
#define pl_CurrentInput(intf) (playlist_CurrentInput(pl_Get(intf)))
/**
* \defgroup vlc_subscription Log messages subscription
* These functions deal with log messages.
* @ingroup messages
* @{
*/
/**
* Message logging callback signature.
* \param data data pointer as provided to vlc_msg_SetCallback().
* \param type message type (VLC_MSG_* values from enum vlc_log_type)
* \param item meta information
* \param fmt format string
* \param args format string arguments
*/
typedef
void
(
*
vlc_log_cb
)
(
void
*
data
,
int
type
,
const
vlc_log_t
*
item
,
const
char
*
fmt
,
va_list
args
);
VLC_API
void
vlc_LogSet
(
libvlc_int_t
*
,
vlc_log_cb
cb
,
void
*
data
);
/*@}*/
...
...
This diff is collapsed.
Click to expand it.
include/vlc_messages.h
+
11
−
0
View file @
8fa96a46
...
...
@@ -84,6 +84,17 @@ VLC_API void vlc_vaLog(vlc_object_t *, int,
VLC_API
const
char
*
vlc_strerror
(
int
);
VLC_API
const
char
*
vlc_strerror_c
(
int
);
/**
* Message logging callback signature.
* \param data data pointer as provided to vlc_msg_SetCallback().
* \param type message type (VLC_MSG_* values from enum vlc_log_type)
* \param item meta information
* \param fmt format string
* \param args format string arguments
*/
typedef
void
(
*
vlc_log_cb
)
(
void
*
data
,
int
type
,
const
vlc_log_t
*
item
,
const
char
*
fmt
,
va_list
args
);
/**
* @}
*/
...
...
This diff is collapsed.
Click to expand it.
src/libvlc.c
+
4
−
4
View file @
8fa96a46
...
...
@@ -168,8 +168,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
int
vlc_optind
;
if
(
config_LoadCmdLine
(
p_libvlc
,
i_argc
,
ppsz_argv
,
&
vlc_optind
)
)
{
module_EndBank
(
true
);
vlc_LogDeinit
(
p_libvlc
);
module_EndBank
(
true
);
return
VLC_EGENERIC
;
}
...
...
@@ -194,8 +194,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if
(
module_count
<=
1
)
{
msg_Err
(
p_libvlc
,
"No plugins found! Check your VLC installation."
);
module_EndBank
(
true
);
vlc_LogDeinit
(
p_libvlc
);
module_EndBank
(
true
);
return
VLC_ENOMOD
;
}
...
...
@@ -206,8 +206,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if
(
daemon
(
1
,
0
)
!=
0
)
{
msg_Err
(
p_libvlc
,
"Unable to fork vlc to daemon mode"
);
module_EndBank
(
true
);
vlc_LogDeinit
(
p_libvlc
);
module_EndBank
(
true
);
return
VLC_ENOMEM
;
}
...
...
@@ -552,8 +552,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
config_AutoSaveConfigFile
(
VLC_OBJECT
(
p_libvlc
)
);
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank
(
true
);
vlc_LogDeinit
(
p_libvlc
);
module_EndBank
(
true
);
#if defined(_WIN32) || defined(__OS2__)
system_End
(
);
#endif
...
...
This diff is collapsed.
Click to expand it.
src/misc/messages.c
+
66
−
19
View file @
8fa96a46
...
...
@@ -40,6 +40,7 @@
#include
<vlc_common.h>
#include
<vlc_interface.h>
#include
<vlc_charset.h>
#include
<vlc_modules.h>
#include
"../libvlc.h"
#ifdef __ANDROID__
...
...
@@ -52,6 +53,7 @@ struct vlc_logger_t
vlc_rwlock_t
lock
;
vlc_log_cb
log
;
void
*
sys
;
module_t
*
module
;
};
static
void
vlc_vaLogCallback
(
libvlc_int_t
*
vlc
,
int
type
,
...
...
@@ -355,8 +357,9 @@ static int vlc_LogEarlyOpen(vlc_logger_t *logger)
return
0
;
}
static
void
vlc_LogEarlyClose
(
lib
vlc_
int_t
*
vlc
,
void
*
d
)
static
void
vlc_LogEarlyClose
(
vlc_
logger_t
*
logger
,
void
*
d
)
{
libvlc_int_t
*
vlc
=
logger
->
p_libvlc
;
vlc_logger_early_t
*
sys
=
d
;
/* Drain early log messages */
...
...
@@ -379,6 +382,25 @@ static void vlc_vaLogDiscard(void *d, int type, const vlc_log_t *item,
(
void
)
d
;
(
void
)
type
;
(
void
)
item
;
(
void
)
format
;
(
void
)
ap
;
}
static
int
vlc_logger_load
(
void
*
func
,
va_list
ap
)
{
vlc_log_cb
(
*
activate
)(
vlc_object_t
*
,
void
**
)
=
func
;
vlc_logger_t
*
logger
=
va_arg
(
ap
,
vlc_logger_t
*
);
vlc_log_cb
*
cb
=
va_arg
(
ap
,
vlc_log_cb
*
);
void
**
sys
=
va_arg
(
ap
,
void
**
);
*
cb
=
activate
(
VLC_OBJECT
(
logger
),
sys
);
return
(
*
cb
!=
NULL
)
?
VLC_SUCCESS
:
VLC_EGENERIC
;
}
static
void
vlc_logger_unload
(
void
*
func
,
va_list
ap
)
{
void
(
*
deactivate
)(
vlc_logger_t
*
)
=
func
;
void
*
sys
=
va_arg
(
ap
,
void
*
);
deactivate
(
sys
);
}
/**
* Performs preinitialization of the messages logging subsystem.
*
...
...
@@ -422,41 +444,52 @@ int vlc_LogPreinit(libvlc_int_t *vlc)
int
vlc_LogInit
(
libvlc_int_t
*
vlc
)
{
vlc_logger_t
*
logger
=
libvlc_priv
(
vlc
)
->
logger
;
void
*
early_sys
=
NULL
;
vlc_log_cb
cb
=
PrintMsg
;
signed
char
verbosity
;
if
(
unlikely
(
logger
==
NULL
))
return
-
1
;
vlc_log_cb
cb
;
void
*
sys
,
*
early_sys
=
NULL
;
/* TODO: module configuration item */
module_t
*
module
=
vlc_module_load
(
logger
,
"logger"
,
NULL
,
false
,
vlc_logger_load
,
logger
,
&
cb
,
&
sys
);
if
(
module
==
NULL
)
{
#ifdef __ANDROID__
cb
=
AndroidPrintMsg
;
cb
=
AndroidPrintMsg
;
#elif defined (HAVE_ISATTY) && !defined (_WIN32)
if
(
isatty
(
STDERR_FILENO
)
&&
var_InheritBool
(
vlc
,
"color"
))
cb
=
PrintColorMsg
;
if
(
isatty
(
STDERR_FILENO
)
&&
var_InheritBool
(
vlc
,
"color"
))
cb
=
PrintColorMsg
;
#endif
else
cb
=
PrintMsg
;
if
(
var_InheritBool
(
vlc
,
"quiet"
))
verbosity
=
-
1
;
else
{
const
char
*
str
=
getenv
(
"VLC_VERBOSE"
);
signed
char
verbosity
;
if
(
var_InheritBool
(
vlc
,
"quiet"
))
verbosity
=
-
1
;
else
{
const
char
*
str
=
getenv
(
"VLC_VERBOSE"
);
if
(
str
==
NULL
||
sscanf
(
str
,
"%hhd"
,
&
verbosity
)
<
1
)
verbosity
=
var_InheritInteger
(
vlc
,
"verbose"
);
if
(
str
==
NULL
||
sscanf
(
str
,
"%hhd"
,
&
verbosity
)
<
1
)
verbosity
=
var_InheritInteger
(
vlc
,
"verbose"
);
}
sys
=
(
void
*
)(
intptr_t
)
verbosity
;
}
vlc_rwlock_wrlock
(
&
logger
->
lock
);
if
(
logger
->
log
==
vlc_vaLogEarly
)
early_sys
=
logger
->
sys
;
logger
->
log
=
cb
;
logger
->
sys
=
(
void
*
)(
intptr_t
)
verbosity
;
logger
->
sys
=
sys
;
assert
(
logger
->
module
==
NULL
);
/* Only one call to vlc_LogInit()! */
logger
->
module
=
module
;
vlc_rwlock_unlock
(
&
logger
->
lock
);
if
(
early_sys
!=
NULL
)
vlc_LogEarlyClose
(
vlc
,
early_sys
);
vlc_LogEarlyClose
(
logger
,
early_sys
);
return
0
;
}
...
...
@@ -473,14 +506,24 @@ void vlc_LogSet(libvlc_int_t *vlc, vlc_log_cb cb, void *opaque)
if
(
unlikely
(
logger
==
NULL
))
return
;
module_t
*
module
;
void
*
sys
;
if
(
cb
==
NULL
)
cb
=
vlc_vaLogDiscard
;
vlc_rwlock_wrlock
(
&
logger
->
lock
);
sys
=
logger
->
sys
;
module
=
logger
->
module
;
logger
->
log
=
cb
;
logger
->
sys
=
opaque
;
logger
->
module
=
NULL
;
vlc_rwlock_unlock
(
&
logger
->
lock
);
if
(
module
!=
NULL
)
vlc_module_unload
(
module
,
vlc_logger_unload
,
sys
);
/* Announce who we are */
msg_Dbg
(
vlc
,
"VLC media player - %s"
,
VERSION_MESSAGE
);
msg_Dbg
(
vlc
,
"%s"
,
COPYRIGHT_MESSAGE
);
...
...
@@ -495,13 +538,17 @@ void vlc_LogDeinit(libvlc_int_t *vlc)
if
(
unlikely
(
logger
==
NULL
))
return
;
if
(
logger
->
module
!=
NULL
)
vlc_module_unload
(
logger
->
module
,
vlc_logger_unload
,
logger
->
sys
);
else
/* Flush early log messages (corner case: no call to vlc_LogInit()) */
if
(
logger
->
log
==
vlc_vaLogEarly
)
{
logger
->
log
=
vlc_vaLogDiscard
;
vlc_LogEarlyClose
(
vlc
,
logger
->
sys
);
vlc_LogEarlyClose
(
logger
,
logger
->
sys
);
}
vlc_rwlock_destroy
(
&
logger
->
lock
);
vlc_object_release
(
logger
);
libvlc_priv
(
vlc
)
->
logger
=
NULL
;
}
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