Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
49006c59
Commit
49006c59
authored
Feb 08, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: convert console logger to module
parent
8fa96a46
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
92 deletions
+145
-92
modules/Makefile.am
modules/Makefile.am
+1
-0
modules/logger/Makefile.am
modules/logger/Makefile.am
+5
-0
modules/logger/console.c
modules/logger/console.c
+135
-0
src/libvlc-module.c
src/libvlc-module.c
+0
-8
src/misc/messages.c
src/misc/messages.c
+4
-84
No files found.
modules/Makefile.am
View file @
49006c59
...
...
@@ -41,6 +41,7 @@ include audio_output/Makefile.am
include
codec/Makefile.am
include
demux/Makefile.am
include
hw/vdpau/Makefile.am
include
logger/Makefile.am
include
lua/Makefile.am
include
meta_engine/Makefile.am
include
misc/Makefile.am
...
...
modules/logger/Makefile.am
0 → 100644
View file @
49006c59
loggerdir
=
$(pluginsdir)
/logger
libconsole_logger_plugin_la_SOURCES
=
logger/console.c
logger_LTLIBRARIES
=
libconsole_logger_plugin.la
modules/logger/console.c
0 → 100644
View file @
49006c59
/*****************************************************************************
* console.c: console logger
*****************************************************************************
* Copyright © 1998-2005 VLC authors and VideoLAN
* Copyright © 2006-2015 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdarg.h>
#include <stdio.h>
#include <inttypes.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
static
const
int
ptr_width
=
2
*
/* hex digits */
sizeof
(
uintptr_t
);
static
const
char
msg_type
[
4
][
9
]
=
{
""
,
" error"
,
" warning"
,
" debug"
};
#ifndef _WIN32
# define COL(x,y) "\033[" #x ";" #y "m"
# define RED COL(31,1)
# define GREEN COL(32,1)
# define YELLOW COL(0,33)
# define WHITE COL(0,1)
# define GRAY "\033[0m"
static
const
char
msg_color
[
4
][
8
]
=
{
WHITE
,
RED
,
YELLOW
,
GRAY
};
static
void
LogConsoleColor
(
void
*
opaque
,
int
type
,
const
vlc_log_t
*
meta
,
const
char
*
format
,
va_list
ap
)
{
FILE
*
stream
=
stderr
;
int
verbose
=
(
intptr_t
)
opaque
;
if
(
verbose
<
type
)
return
;
int
canc
=
vlc_savecancel
();
flockfile
(
stream
);
fprintf
(
stream
,
"["
GREEN
"%0*"
PRIxPTR
GRAY
"] "
,
ptr_width
,
meta
->
i_object_id
);
if
(
meta
->
psz_header
!=
NULL
)
fprintf
(
stream
,
"[%s] "
,
meta
->
psz_header
);
fprintf
(
stream
,
"%s %s%s: %s"
,
meta
->
psz_module
,
meta
->
psz_object_type
,
msg_type
[
type
],
msg_color
[
type
]);
vfprintf
(
stream
,
format
,
ap
);
fputs
(
GRAY
"
\n
"
,
stream
);
funlockfile
(
stream
);
vlc_restorecancel
(
canc
);
}
#endif
/* !_WIN32 */
static
void
LogConsoleGray
(
void
*
opaque
,
int
type
,
const
vlc_log_t
*
meta
,
const
char
*
format
,
va_list
ap
)
{
FILE
*
stream
=
stderr
;
int
verbose
=
(
intptr_t
)
opaque
;
if
(
verbose
<
type
)
return
;
int
canc
=
vlc_savecancel
();
flockfile
(
stream
);
fprintf
(
stream
,
"[%0*"
PRIxPTR
"] "
,
ptr_width
,
meta
->
i_object_id
);
if
(
meta
->
psz_header
!=
NULL
)
fprintf
(
stream
,
"[%s] "
,
meta
->
psz_header
);
fprintf
(
stream
,
"%s %s%s: "
,
meta
->
psz_module
,
meta
->
psz_object_type
,
msg_type
[
type
]);
vfprintf
(
stream
,
format
,
ap
);
putc_unlocked
(
'\n'
,
stream
);
funlockfile
(
stream
);
vlc_restorecancel
(
canc
);
}
static
vlc_log_cb
Open
(
vlc_object_t
*
obj
,
void
**
sysp
)
{
int
verbosity
=
-
1
;
if
(
!
var_InheritBool
(
obj
,
"quiet"
))
{
const
char
*
str
=
getenv
(
"VLC_VERBOSE"
);
if
(
str
!=
NULL
)
verbosity
=
atoi
(
str
);
else
verbosity
=
var_InheritInteger
(
obj
,
"verbose"
);
}
if
(
verbosity
<
0
)
return
NULL
;
verbosity
+=
VLC_MSG_ERR
;
*
sysp
=
(
void
*
)(
uintptr_t
)
verbosity
;
#if defined (HAVE_ISATTY) && !defined (_WIN32)
if
(
isatty
(
STDERR_FILENO
)
&&
var_InheritBool
(
obj
,
"color"
))
return
LogConsoleColor
;
#endif
return
LogConsoleGray
;
}
#define QUIET_TEXT N_("Be quiet")
#define QUIET_LONGTEXT N_("Turn off all messages on the console.")
vlc_module_begin
()
set_shortname
(
N_
(
"Console log"
))
set_description
(
N_
(
"Console logger"
))
set_category
(
CAT_ADVANCED
)
set_subcategory
(
SUBCAT_ADVANCED_MISC
)
set_capability
(
"logger"
,
10
)
set_callbacks
(
Open
,
NULL
)
add_bool
(
"quiet"
,
false
,
QUIET_TEXT
,
QUIET_LONGTEXT
,
false
)
change_short
(
'q'
)
change_volatile
()
vlc_module_end
()
src/libvlc-module.c
View file @
49006c59
...
...
@@ -85,10 +85,6 @@ static const char *const ppsz_snap_formats[] =
"This is the verbosity level (0=only errors and " \
"standard messages, 1=warnings, 2=debug).")
#define QUIET_TEXT N_("Be quiet")
#define QUIET_LONGTEXT N_( \
"Turn off all warning and information messages.")
#define OPEN_TEXT N_("Default stream")
#define OPEN_LONGTEXT N_( \
"This stream will always be opened at VLC startup." )
...
...
@@ -2034,10 +2030,6 @@ vlc_module_begin ()
change_short
(
'v'
)
change_volatile
()
add_obsolete_string
(
"verbose-objects"
)
/* since 2.1.0 */
add_bool
(
"quiet"
,
0
,
QUIET_TEXT
,
QUIET_LONGTEXT
,
false
)
change_short
(
'q'
)
change_volatile
()
#if !defined(_WIN32) && !defined(__OS2__)
add_bool
(
"daemon"
,
0
,
DAEMON_TEXT
,
DAEMON_LONGTEXT
,
true
)
change_short
(
'd'
)
...
...
src/misc/messages.c
View file @
49006c59
...
...
@@ -154,71 +154,9 @@ void vlc_Log(vlc_object_t *obj, int type, const char *module,
va_end
(
ap
);
}
#ifdef _WIN32
static
const
char
msg_type
[
4
][
9
]
=
{
""
,
" error"
,
" warning"
,
" debug"
};
#define COL(x,y) "\033[" #x ";" #y "m"
#define RED COL(31,1)
#define GREEN COL(32,1)
#define YELLOW COL(0,33)
#define WHITE COL(0,1)
#define GRAY "\033[0m"
static
const
char
msg_color
[
4
][
8
]
=
{
WHITE
,
RED
,
YELLOW
,
GRAY
};
/* Display size of a pointer */
static
const
int
ptr_width
=
2
*
/* hex digits */
sizeof
(
uintptr_t
);
static
void
PrintColorMsg
(
void
*
d
,
int
type
,
const
vlc_log_t
*
p_item
,
const
char
*
format
,
va_list
ap
)
{
FILE
*
stream
=
stderr
;
int
verbose
=
(
intptr_t
)
d
;
if
(
verbose
<
0
||
verbose
<
(
type
-
VLC_MSG_ERR
))
return
;
int
canc
=
vlc_savecancel
();
flockfile
(
stream
);
utf8_fprintf
(
stream
,
"["
GREEN
"%0*"
PRIxPTR
""
GRAY
"] "
,
ptr_width
,
p_item
->
i_object_id
);
if
(
p_item
->
psz_header
!=
NULL
)
utf8_fprintf
(
stream
,
"[%s] "
,
p_item
->
psz_header
);
utf8_fprintf
(
stream
,
"%s %s%s: %s"
,
p_item
->
psz_module
,
p_item
->
psz_object_type
,
msg_type
[
type
],
msg_color
[
type
]);
utf8_vfprintf
(
stream
,
format
,
ap
);
fputs
(
GRAY
"
\n
"
,
stream
);
#if defined (_WIN32) || defined (__OS2__)
fflush
(
stream
);
#endif
funlockfile
(
stream
);
vlc_restorecancel
(
canc
);
}
static
void
PrintMsg
(
void
*
d
,
int
type
,
const
vlc_log_t
*
p_item
,
const
char
*
format
,
va_list
ap
)
{
FILE
*
stream
=
stderr
;
int
verbose
=
(
intptr_t
)
d
;
if
(
verbose
<
0
||
verbose
<
(
type
-
VLC_MSG_ERR
))
return
;
int
canc
=
vlc_savecancel
();
flockfile
(
stream
);
utf8_fprintf
(
stream
,
"[%0*"
PRIxPTR
"] "
,
ptr_width
,
p_item
->
i_object_id
);
if
(
p_item
->
psz_header
!=
NULL
)
utf8_fprintf
(
stream
,
"[%s] "
,
p_item
->
psz_header
);
utf8_fprintf
(
stream
,
"%s %s%s: "
,
p_item
->
psz_module
,
p_item
->
psz_object_type
,
msg_type
[
type
]);
utf8_vfprintf
(
stream
,
format
,
ap
);
putc_unlocked
(
'\n'
,
stream
);
#if defined (_WIN32) || defined (__OS2__)
fflush
(
stream
);
#endif
funlockfile
(
stream
);
vlc_restorecancel
(
canc
);
}
#ifdef _WIN32
static
void
Win32DebugOutputMsg
(
void
*
d
,
int
type
,
const
vlc_log_t
*
p_item
,
const
char
*
format
,
va_list
dol
)
{
...
...
@@ -454,29 +392,11 @@ int vlc_LogInit(libvlc_int_t *vlc)
module_t
*
module
=
vlc_module_load
(
logger
,
"logger"
,
NULL
,
false
,
vlc_logger_load
,
logger
,
&
cb
,
&
sys
);
if
(
module
==
NULL
)
{
#ifdef __ANDROID__
cb
=
AndroidPrintMsg
;
#elif defined (HAVE_ISATTY) && !defined (_WIN32)
if
(
isatty
(
STDERR_FILENO
)
&&
var_InheritBool
(
vlc
,
"color"
))
cb
=
PrintColorMsg
;
cb
=
AndroidPrintMsg
,
sys
=
NULL
;
#else
cb
=
vlc_vaLogDiscard
;
#endif
else
cb
=
PrintMsg
;
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"
);
}
sys
=
(
void
*
)(
intptr_t
)
verbosity
;
}
vlc_rwlock_wrlock
(
&
logger
->
lock
);
if
(
logger
->
log
==
vlc_vaLogEarly
)
...
...
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