示例#1
0
void vlc_LogInit (libvlc_int_t *vlc)
{
    libvlc_priv_t *priv = libvlc_priv (vlc);
    const char *str;

    if (var_InheritBool (vlc, "quiet"))
        priv->log.verbose = -1;
    else
    if ((str = getenv ("VLC_VERBOSE")) != NULL)
        priv->log.verbose = atoi (str);
    else
        priv->log.verbose = var_InheritInteger (vlc, "verbose");

    vlc_rwlock_init (&priv->log.lock);
    vlc_LogSet (vlc, NULL, NULL);
}
示例#2
0
文件: logger.c 项目: nunoneto/vlc
/*****************************************************************************
 * Open: initialize and create stuff
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    intf_thread_t *p_intf = (intf_thread_t *)p_this;
    intf_sys_t *p_sys;

    CONSOLE_INTRO_MSG;
    msg_Info( p_intf, "using logger." );

    /* Allocate instance and initialize some members */
    p_sys = p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
    if( p_sys == NULL )
        return VLC_ENOMEM;

    p_sys->p_file = NULL;
    vlc_log_cb cb = TextPrint;
    const char *filename = LOG_FILE_TEXT, *header = TEXT_HEADER;
    p_sys->footer = TEXT_FOOTER;

    char *mode = var_InheritString( p_intf, "logmode" );
    if( mode != NULL )
    {
        if( !strcmp( mode, "html" ) )
        {
            p_sys->footer = HTML_FOOTER;
            header = HTML_HEADER;
            cb = HtmlPrint;
        }
#ifdef HAVE_SYSLOG_H
        else if( !strcmp( mode, "syslog" ) )
            cb = SyslogPrint;
#endif
#ifdef __ANDROID__
        else if( !strcmp( mode, "android" ) )
            cb = AndroidPrint;
#endif
        else if( strcmp( mode, "text" ) )
            msg_Warn( p_intf, "invalid log mode `%s', using `text'", mode );
        free( mode );
    }

#ifdef HAVE_SYSLOG_H
    if( cb == SyslogPrint )
    {
        int i_facility;
        char *psz_facility = var_InheritString( p_intf, "syslog-facility" );
        if( psz_facility )
        {
            bool b_valid = 0;
            for( size_t i = 0; i < fac_entries; ++i )
            {
                if( !strcmp( psz_facility, fac_name[i] ) )
                {
                    i_facility = fac_number[i];
                    b_valid = 1;
                    break;
                }
            }
            if( !b_valid )
            {
                msg_Warn( p_intf, "invalid syslog facility `%s', using `%s'",
                          psz_facility, fac_name[0] );
                i_facility = fac_number[0];
            }
            free( psz_facility );
        }
        else
        {
            msg_Warn( p_intf, "no syslog facility specified, using `%s'",
                      fac_name[0] );
            i_facility = fac_number[0];
        }

        char *psz_syslog_ident = var_InheritString( p_intf, "syslog-ident" );
        if (unlikely(psz_syslog_ident == NULL))
        {
            free( p_sys );
            return VLC_ENOMEM;
        }

        p_sys->ident = psz_syslog_ident;
        openlog( p_sys->ident, LOG_PID|LOG_NDELAY, i_facility );

        p_sys->p_file = NULL;
    }
    else
#endif
#ifdef __ANDROID__
        if( cb == AndroidPrint )
        {
            /* nothing to do */
        }
        else
#endif
        {
            char *psz_file = var_InheritString( p_intf, "logfile" );
            if( !psz_file )
            {
#ifdef __APPLE__
# define LOG_DIR "Library/Logs"
                char *home = config_GetUserDir(VLC_HOME_DIR);
                if( home == NULL
                        || asprintf( &psz_file, "%s/"LOG_DIR"/%s", home,
                                     filename ) == -1 )
                    psz_file = NULL;
                free(home);
                filename = psz_file;
#endif
                msg_Warn( p_intf, "no log filename provided, using `%s'",
                          filename );
            }
            else
                filename = psz_file;

            /* Open the log file and remove any buffering for the stream */
            msg_Dbg( p_intf, "opening logfile `%s'", filename );
            p_sys->p_file = vlc_fopen( filename, "at" );
            if( p_sys->p_file == NULL )
            {
                msg_Err( p_intf, "error opening logfile `%s': %m", filename );
                free( psz_file );
                free( p_sys );
                return VLC_EGENERIC;
            }
            free( psz_file );
            setvbuf( p_sys->p_file, NULL, _IONBF, 0 );
            fputs( header, p_sys->p_file );
        }

    vlc_LogSet( p_intf->p_libvlc, cb, p_intf );
    return VLC_SUCCESS;
}
示例#3
0
文件: messages.cpp 项目: AsamQi/vlc
MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
               : QVLCFrame( _p_intf )
{
    setWindowTitle( qtr( "Messages" ) );
    setWindowRole( "vlc-messages" );
    /* Build Ui */
    ui.setupUi( this );
    ui.bottomButtonsBox->addButton( new QPushButton( qtr("&Close"), this ),
                                         QDialogButtonBox::RejectRole );

    /* Modules tree */
    ui.modulesTree->setHeaderHidden( true );

    /* Buttons and general layout */
    ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) );

    int i_verbosity = var_InheritInteger( p_intf, "verbose" );
    changeVerbosity( i_verbosity );
    ui.verbosityBox->setValue( qMin( i_verbosity, 2 ) );

    getSettings()->beginGroup( "Messages" );
    ui.filterEdit->setText( getSettings()->value( "messages-filter" ).toString() );
    getSettings()->endGroup();

    updateButton = new QPushButton( QIcon(":/update"), "" );
    updateButton->setFlat( true );
    ui.mainTab->setCornerWidget( updateButton );

#ifndef NDEBUG
    QWidget *pldebugTab = new QWidget();
    QVBoxLayout *pldebugTabLayout = new QVBoxLayout();
    pldebugTab->setLayout( pldebugTabLayout );
    ui.mainTab->addTab( pldebugTab, "Playlist Tree" );
    pldebugTree = new QTreeWidget();
    pldebugTree->headerItem()->setText( 0, "Name" );
    pldebugTree->headerItem()->setText( 1, "PL id" );
    pldebugTree->headerItem()->setText( 2, "Item id" );
    pldebugTree->headerItem()->setText( 3, "PL flags" );
    pldebugTree->headerItem()->setText( 4, "Item flags" );
    pldebugTree->setColumnCount( 5 );
    pldebugTabLayout->addWidget( pldebugTree );
#endif

    tabChanged(0);

    BUTTONACT( updateButton, updateOrClear() );
    BUTTONACT( ui.saveLogButton, save() );
    CONNECT( ui.filterEdit, editingFinished(), this, updateConfig() );
    CONNECT( ui.filterEdit, textChanged(QString), this, filterMessages() );
    CONNECT( ui.bottomButtonsBox, rejected(), this, hide() );
    CONNECT( ui.verbosityBox, valueChanged( int ),
             this, changeVerbosity( int ) );

    CONNECT( ui.mainTab, currentChanged( int ), this, tabChanged( int ) );

    /* General action */
    restoreWidgetPosition( "Messages", QSize( 600, 450 ) );

    /* Hook up to LibVLC messaging */
    vlc_LogSet( p_intf->p_libvlc, MsgCallback, this );

    buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
}
示例#4
0
文件: logger.c 项目: BossKing/vlc
/*****************************************************************************
 * Close: destroy interface stuff
 *****************************************************************************/
static void Close( vlc_object_t *p_this )
{
    /* Flush the queue and unsubscribe from the message queue */
    vlc_LogSet( p_this->obj.libvlc, NULL, NULL );
}
示例#5
0
文件: messages.cpp 项目: AsamQi/vlc
MessagesDialog::~MessagesDialog()
{
    saveWidgetPosition( "Messages" );
    vlc_LogSet( p_intf->p_libvlc, NULL, NULL );
};