示例#1
0
TEST_F(LoggerTests, test_logger_status_level) {
  auto minloglevel = FLAGS_minloglevel;
  FLAGS_minloglevel = 0;
  // This will be printed to stdout.
  LOG(INFO) << "Logger test is generating an info status";
  EXPECT_EQ(1U, LoggerTests::statuses_logged);

  FLAGS_minloglevel = 1;
  setVerboseLevel();

  LOG(INFO) << "Logger test is generating an info status";
  EXPECT_EQ(1U, LoggerTests::statuses_logged);
  LOG(WARNING) << "Logger test is generating a warning status";
  EXPECT_EQ(2U, LoggerTests::statuses_logged);
  FLAGS_minloglevel = minloglevel;

  auto stderrthreshold = FLAGS_stderrthreshold;
  FLAGS_stderrthreshold = 2;
  setVerboseLevel();

  LOG(WARNING) << "Logger test is generating a warning status";
  EXPECT_EQ(3U, LoggerTests::statuses_logged);
  FLAGS_stderrthreshold = stderrthreshold;

  auto logger_min_status = FLAGS_logger_min_status;
  FLAGS_logger_min_status = 1;
  setVerboseLevel();

  LOG(INFO) << "Logger test is generating an info status";
  EXPECT_EQ(3U, LoggerTests::statuses_logged);
  LOG(WARNING) << "Logger test is generating a warning status";
  EXPECT_EQ(4U, LoggerTests::statuses_logged);
  FLAGS_logger_min_status = logger_min_status;
}
示例#2
0
文件: Newswire.cpp 项目: loh-tar/filu
void Newswire::setVerboseLevel(const QString& func, const QStringList& parm)
{
    QStringList level;
    if(FTool::getParameter(parm, "--verbose", level) < 1) return; // We ignore that fault

    setVerboseLevel(func, level.at(0));
}
示例#3
0
  Status update(const std::map<std::string, pt::ptree>& config) {
    if (config.count("options") > 0) {
      data_ = pt::ptree();
      data_.put_child("options", config.at("options"));
    }

    const auto& options = data_.get_child("options");
    for (const auto& option : options) {
      std::string value = options.get<std::string>(option.first, "");
      if (value.empty()) {
        continue;
      }

      Flag::updateValue(option.first, value);
      // There is a special case for supported Gflags-reserved switches.
      if (option.first == "verbose" || option.first == "verbose_debug" ||
          option.first == "debug") {
        setVerboseLevel();
        if (Flag::getValue("verbose") == "true") {
          VLOG(1) << "Verbose logging enabled by config option";
        }
      }
    }

    return Status(0, "OK");
  }
示例#4
0
文件: Newswire.cpp 项目: loh-tar/filu
void Newswire::setVerboseLevel(const QString& func, const QString& level)
{
    bool ok;
    mVerboseLevel = VerboseLevel(level.toInt(&ok));

    if(ok and (mVerboseLevel >= eNoVerbose) and (mVerboseLevel <= eMax)) return;

    QString levelName = level.toUpper();
    if(levelName == "QUIET")      setVerboseLevel(eNoVerbose);
    else if(levelName == "INFO")  setVerboseLevel(eInfo);
    else if(levelName == "AMPLE") setVerboseLevel(eAmple);
    else if(levelName == "MAX")   setVerboseLevel(eMax);
    else
    {
        error(func, tr("Verbose level '%1' unknown.").arg(level));
        setVerboseLevel(eAmple);
    }
}
示例#5
0
文件: AgentF.cpp 项目: loh-tar/filu
void AgentF::exec(const QStringList& parm)
{
  if(mFilu->hasError()) return;

  // mCmd->regCmds("this...") is done in ctor !
  // mCmd->regOpts("verbose");

  if(mCmd->cmdLineLooksBad(parm)) return;

  if(mCmd->has("verbose")) setVerboseLevel(FUNC, mCmd->cmdLine());

  if(mCmd->wantHelp())
  {
    mCmd->inCmdBrief("full", tr("Download eod bars of all FIs"));
    mCmd->inCmdBrief("info", tr("Print some settings and more"));

    CmdClass::allBriefIn(mCmd);

    Depots::briefIn(mCmd);
    Scanner::briefIn(mCmd);
    Exporter::briefIn(mCmd);

    mCmd->inOptBrief("verbose", "<Level>"
                              , tr("How talkative has it to be. Level can be 0-3 or "
                                   "Quiet Info Ample Max"));
  }
  else
  {
    QStringList cmd = parm;
    cmd.removeAt(0);
    record(FUNC, tr("Exec: %1").arg(cmd.join(" ")));
  }

  if(mCmd->needHelp(1))
  {
    if(mCmd->printThisWay("<Command> [<ParmList>] [<SubCommand> [<ParmList>]]..")) return;

    mCmd->printComment(tr("Calling a command without any parameter may give a hint like --help."));
    mCmd->printComment(tr("But of cause not if no parameter is needed e.g at 'full'."));
    mCmd->aided();
    return;
  }

  // Look for each known command and call the related function
  if(mKnownCmds.contains(mCmd->cmd()))   cmdExec(mCmd->cmd());
  else if(mCmd->hasCmd("full"))          updateAllBars();
  else if(mCmd->hasCmd("exp"))           exxport();
  else if(mCmd->hasCmd("scan"))          scan();
  else if(mCmd->hasCmd("depots"))        depots();
  else if(mCmd->hasCmd("info"))          printSettings();
  else
  {
    fatal(FUNC, QString("Unsupported command: %1").arg(mCmd->cmd()));
  }
}
示例#6
0
	void init()
	{
		setRenderScale( 1.0, 1.0 );
		setVerboseLevel( eVerboseLevelWarning );
		setReturnBuffers            ( true  );
		setContinueOnError          ( false );
		setContinueOnMissingFile    ( false );
		setColorEnable              ( false );
		setIsInteractive            ( false );
		setForceIdentityNodesProcess( false );
	}
示例#7
0
文件: Newswire.cpp 项目: loh-tar/filu
Newswire::Newswire(const QString& connectionName)
    : mRoot(true)
    , mConnName(connectionName)
    , mClass(connectionName)
    , mVerboseLevel(eInfo)
    , mHasError(false)
    , mHasFatal(false)
    , mConsole(new QTextStream(stdout))
    , mErrConsole(new QTextStream(stderr))
    , mLogFileFile(0)
    , mLogFile(0)
    , mNoErrorLogging(false)
    , mNoFileLogging(false)
    , mNoAutoClearMessages(false)
{
    setVerboseLevel(mVerboseLevel); // Is called to set mFormat
}
示例#8
0
void initStatusLogger(const std::string& name) {
  FLAGS_alsologtostderr = false;
  FLAGS_logbufsecs = 0; // flush the log buffer immediately
  FLAGS_stop_logging_if_full_disk = true;
  FLAGS_max_log_size = 10; // max size for individual log file is 10MB
  FLAGS_logtostderr = true;

  setVerboseLevel();
  // Start the logging, and announce the daemon is starting.
  google::InitGoogleLogging(name.c_str());

  // If logging is disabled then do not buffer intermediate logs.
  if (!FLAGS_disable_logging) {
    // Create an instance of the buffered log sink and do not forward logs yet.
    BufferedLogSink::enable();
  }
}
示例#9
0
inline void mergeOption(const tree_node& option, ConfigData& conf) {
  std::string key = option.first.data();
  std::string value = option.second.data();

  Flag::updateValue(key, value);
  // There is a special case for supported Gflags-reserved switches.
  if (key == "verbose" || key == "verbose_debug" || key == "debug") {
    setVerboseLevel();
    if (Flag::getValue("verbose") == "true") {
      VLOG(1) << "Verbose logging enabled by config option";
    }
  }

  conf.options[key] = value;
  if (conf.all_data.count("options") > 0) {
    conf.all_data.get_child("options").erase(key);
  }
  conf.all_data.add_child("options." + key, option.second);
}
示例#10
0
bool CmdHelper::cmdLineLooksBad(const QStringList& cmdLine)
{
  // At first (1st Level) we expect a command without subcommand like:
  //   <Prog> <Command> [<ParmList>] [<OptList>]
  //
  // Returns false if <Command> is Ok or --help was given otherwise true.

  if(!mCmds.size())
  {
    fatal(FUNC, "No commands registered.");
    return true;
  }

  mOptions.clear();
  mSubCmds.clear();
  mMandatory.clear();
  mCmdLine   = cmdLine;
  mHelpLevel = 1;
  unSet("WantHelp");

  // Can't call if(has("verbose")) at this point
  if(mCmdLine.contains("--verbose")) setVerboseLevel(FUNC, mCmdLine);
  setMsgTargetFormat(eFileLog, "%D %T %C: *** %t *** %c: %x");

  // Find any help request and remove it from mCmdLine
  int helpPos = mCmdLine.indexOf("-h+");
  if(helpPos < 0) helpPos = mCmdLine.indexOf("--help+");
  if(helpPos > 0) set("Help+");

  if(helpPos < 0) helpPos = mCmdLine.indexOf("-h");
  if(helpPos < 0) helpPos = mCmdLine.indexOf("--help");

  if(helpPos < 0)
  {
    if(mCmdLine.size() > 1)
    {
      if("help" == mCmdLine.at(1)) helpPos = 1;
      else if("help+" == mCmdLine.at(1))
      {
        helpPos = 1;
        set("Help+");
      }
    }

    if(mCmdLine.size() > 2)
    {
      if("help" == mCmdLine.at(2)) helpPos = 2;
      else if("help+" == mCmdLine.at(2))
      {
        helpPos = 2;
        set("Help+");
      }
    }
  }

  if(helpPos > 0)
  {
    set("WantHelp");
    mCmdLine.removeAt(helpPos);
  }

  if(mCmdLine.size() < 2)
  {
    if(wantHelp()) return false;

    // Called without <Command>, only "<Prog>"
    if(mLabel.contains("<>Greeter<>")) print(mLabel.value("<>Greeter<>"));
    print(tr("Try: %1 -h [<%2>]").arg(mCmdLine.at(0), cCommand));

    printCommands(mCmds);
    return true;
  }

  QString cmd = mCmdLine.at(1);

  if(!cmd.startsWith("--"))
  {
    mCmdLine[1] = "--" + cmd; // Make sure mCmdLine has "--"
  }
  else
  {
    cmd = cmd.mid(2);
  }

  if(!mCmds.contains(cmd))
  {
    if(wantHelp()) return false;

    error(FUNC, tr("Unknown command: %1").arg(cmd));
    print(tr("Try: %1 [<%2>] -h").arg(mCmdLine.at(0), cCommand));
    printCommands(mCmds);
    return true;
  }

  mHelpLevel = 2;

  // Memorize all positions and parameter counts
  Option opt;
  opt.idxPos = 1;
  opt.parmCount = 0;
  opt.name = mCmdLine.at(1).mid(2);
  for(int i = 2; i < mCmdLine.size(); ++i)
  {
    if(mCmdLine.at(i).startsWith("--"))
    {
      mOptions.insert(opt.name, opt);

      opt.idxPos = i;
      opt.name = mCmdLine.at(i).mid(2);
      opt.parmCount = 0;
    }
    else
    {
      ++opt.parmCount;
    }
  }
  mOptions.insert(opt.name, opt);
  mInqCmd = mOptions.named(cmd);
  mInqOpt = mInqCmd;

  return false;
}
示例#11
0
int main(int argc, char **argv)

{

  OPTION  opt;
  int     err = 0;


  /*
    -- init options and cmdline parsing
  */

  init_PidMemory ();


  if (! cmdline_options (argc,argv, &opt) ) return (-1);

  setVerboseLevel (opt.printdecode);
  setHexPrintMode (opt.printhex);



  indent (0);
  if (! opt.binary_out) {
     if (! opt.hide_copyright) {
        out_nl (1, "%s -- %s ", DVBSNOOP_PROG_VERSION, DVBSNOOP_URL);
     }

     if (! opt.inpPidFile) {
	if (opt.pid != DUMMY_PID) {
		out_nl (9, "   PID   : %d (0x%04x)",opt.pid,opt.pid);
	}
	if ((opt.packet_mode == SECT) && (opt.filterLen > 0)) {		// filter are only for sections

		int i;
		out (9, "   Filter: 0x");
		for (i=0; i < opt.filterLen; i++) {
			out (9,"%02x ",opt.filter[i]);
		}
		out_NL (9);
		out (9, "   Mask  : 0x");
		for (i=0; i < opt.filterLen; i++) {
			out (9,"%02x ",opt.mask[i]);
		}
		out_NL (9);
		out_nl (9, "   Max. Filtersize: %d",DMX_FILTER_SIZE);

	}
	out_nl (9, "   DEMUX : %s",opt.devDemux);
	out_nl (9, "   DVR   : %s",opt.devDvr);
	out_nl (9, "   FRONTEND: %s",opt.devFE);
     }
  }



  initOSSigHandler ();
  init_receive_time ();


	  switch (opt.packet_mode) {
		case SECT:
			err = doReadSECT (&opt);
			break;

		case PS:
		case PES:
			err = doReadPES (&opt);
			break;

		case TS:
			err = doReadTS (&opt);
			break;

		case PIDSCAN:
			err = ts_pidscan (&opt);
			break;

		case PIDBANDWIDTH:
			err = ts_pidbandwidth (&opt);
			break;

		case SCAN_FE_SIGNAL:
			err = do_SignalStrength (&opt);
			break;

		case SCAN_FE_INFO:
			err = do_FE_Info (&opt);
			break;

		default:
			fprintf (stderr,"unknown snoop type (this should never happen).\n");
			break;

	  }




 if ( isSigAbort() ) {
	 out_nl (1,"... aborted (Signal: %d)",isSigAbort());
 }
 restoreOSSigHandler();
 return err;

}