void DProcess::run() { DString buffer; DString cmode; DStringList::iterator it; char * buf; int bufsize = 80 * sizeof( char ); // construct exe line buffer = m_exe; for ( it = m_args.begin() ; it != m_args.end() ; ++it ) { if ( !buffer.isEmpty() ) { buffer.append( " " ); } buffer.append( *it ); } if ( m_com_mode == READ_ONLY) { cmode = "r"; } else { cmode = "w"; } m_file = popen( buffer.c_str(), cmode.c_str() ); if ( !m_file ) { return; } if ( m_com_mode == READ_ONLY) { buf = new char[ bufsize ]; while ( fgets( buf, bufsize, m_file ) != 0 ) { addOutput( buf ); } delete[]( buf ); } pclose( m_file ); m_file = 0; }
void DLogEngineSyslog::insert ( const DString & text, Level loglevel ) { int sysloglevel = LOG_DEBUG; DString message; // write message only if loglevel is highter or equal to minimum log level // or not equal to NONE if ( ( loglevel < m_minLevel ) && ( loglevel != DLogShared::NONE ) ) { return; } switch ( loglevel ) { case DLogShared::NONE: case DLogShared::DEBUG: { sysloglevel = LOG_DEBUG; break; } case DLogShared::VERBOSE: { sysloglevel = LOG_NOTICE; break; } case DLogShared::INFO: { sysloglevel = LOG_INFO; break; } case DLogShared::SIGNALS: { sysloglevel = LOG_INFO; break; } case DLogShared::WARNING: { sysloglevel = LOG_WARNING; break; } case DLogShared::ERROR: { sysloglevel = LOG_ERR; break; } case DLogShared::CRITICAL: { sysloglevel = LOG_CRIT; break; } } message = "["; message.append( DLogParams::toString( loglevel ) ); message.append( "] " ); message.append( text ); syslog ( sysloglevel, "%s", message.c_str() ); }