Example #1
0
void test_Logger(){
    {
        Logger lg;
        lg.Log(LOG_WARN, "Test logger");
        lg.Debug("logger debug");
        lg.Fatal("Fatal test [%s] [%d]", "args", 1);
        lg.SetHandler("test_log");
        lg.SetLevel(LOG_ALL);
        lg.Info("info test [%s]", "args");
        Logger* lg_ptr = Logger::GetLogger("test");
        lg_ptr->Error("You can see me in file test");
        Logger* lg_ptr2 = Logger::GetLogger();
        lg_ptr2->Error("You can see me in console");
    }
    {
        LOG(LOG_DEBUG, "log debug info: %s", "Hello"); 
    }    
    {
        SetLogger(LOG_WARN, "test_logger.log");
        LOG(LOG_DEBUG, "DEBUG NO SEE, you should not see this");
        LOG(LOG_ERROR, "ERROR, you should know");
        LOG(LOG_WARN, "WARN, you should see this");
    }    
    {
        SetLogger(LOG_ALL);
        LOG(LOG_DEBUG, "DEBUG [%d], you should see this", LOG_DEBUG);
        LOG(LOG_WARN,  "LOG_WARN [%d], you should see this", LOG_WARN);
        LOG(LOG_ERROR, "LOG_ERROR [%d], you should see this", LOG_ERROR);
        LOG(LOG_FATAL, "LOG_FATAL [%d], you should see this", LOG_FATAL);
    }
}
Example #2
0
void main()
{
	// ============= Direct test of logger

	Logger *logger = new StdoutLogger();
	logger->SetLogLevel(Logger::LOGLEVEL_INFO);

	logger->Log(Logger::LOGLEVEL_INFO,"DirectTest","DirectTest message on info level.\n",1);
	logger->SetLogLevel(Logger::LOGLEVEL_VERBOSE);
	logger->Log(Logger::LOGLEVEL_INFO,"DirectTest","Not appearing DirectTest message on info level.\n",1);

	Logger::getInstance()->Log(Logger::LOGLEVEL_VERBOSE,"SingletonTest","Appearing singleton test...\n");


	int i=12;

	FileLogger loggerF("d:\\e3.txt");

	Logger::getInstance()->Log(Logger::LOGLEVEL_ERROR,"TAG","Szam:%d %d %s %d\n",1,2,"Hello",3);

	loggerF.close();


	// ============ Direct test of ConfigReader

	SimpleIniConfigReader *SIreader = new SimpleIniConfigReader("test.ini");
	ConfigReader *reader = SIreader;

	bool boolean1 = reader->getBoolValue("main","boolean1");
	bool boolean2 = reader->getBoolValue("main","boolean2");
	bool boolean3 = reader->getBoolValue("main","boolean3");
	const char *str = reader->getStringValue("main","string");
	int integer1 = ConfigReader::getInstance()->getIntValue("main","integer");

	std::cout << "Bools: " << boolean1 << ", " << boolean2 << ", " << boolean3 << std::endl;
	std::cout << "Integer: " << integer1 << std::endl;
	std::cout << "String: " << str << std::endl;

}
int Application::BootstrapApplication(ServiceRegistry* serviceRegistry) const
{
    Logger* logger = serviceRegistry->Get<Logger>();
    MainComponent mainComponent = MainComponent(serviceRegistry);
    mainComponent.SetLayout(GetMainComponentLayout(serviceRegistry->Get<ScaleProvider>()));

    serviceRegistry->Get<TrayIcon>()->Initialize();
    mainComponent.Initialize();

    serviceRegistry->Get<MessageBus>()->OnExit.Subscribe(bind(&Application::Exit, this));

    logger->Log(LogLevels::Trace, L"Application initialized.");

    MSG msg;
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    logger->Log(LogLevels::Trace, L"Application shutdown.");

    return msg.wParam;
}
int Application::Run(HINSTANCE hInstance) const
{
    HANDLE mutex = CreateMutex(nullptr, FALSE, _T("Selected text translate"));
    if (GetLastError() == ERROR_ALREADY_EXISTS)
    {
        FatalAppExit(0, TEXT("SelectedTextTranslate already started!"));
    }

    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);

    ServiceRegistry* serviceRegistry = ApplicationServiceRegistry::GetServiceRegistry();
    Logger* logger = serviceRegistry->Get<Logger>();

    logger->Log(LogLevels::Trace, L"Application start.");

    int result;
    try
    {
        ExceptionHelper::SetupStructuredExceptionsTranslation();
        result = BootstrapApplication(serviceRegistry);
        delete serviceRegistry;
    }
    catch (...)
    {
        ExceptionHelper::TerminateOnException(logger);
        return -1;
    }

    ReleaseMutex(mutex);
    CloseHandle(mutex);

    Gdiplus::GdiplusShutdown(gdiplusToken);

    return result;
}
Example #5
0
void nvlog(char *data, int size) {
  nvlogger.Log((unsigned char *)data, size);
  nvlogger.Flush();
}
Example #6
0
void UMXSendThread::Threadfunc()
{
	HRESULT hResult;
	int ret = 0;
	UmxSender * sender = 0;

	hResult = ::SoraUmxInit(Radio::Current());
	if (FAILED(hResult))
	{
		goto EXIT;
	}

	Radio::Current()->SoraUmxConfigRadio();

	sender = new UmxSender(Radio::Current());
	
	hResult = sender->Init();
	if (FAILED(hResult))
		goto EXIT;

	const int SIZE_2M = 2*1024*1024;
	char * buf = new char[SIZE_2M];
	if (buf == 0)
	{
		Logger::GetLogger(L"umx")->Log(LOG_ERROR, L"Cannot alloc buffer for data reading.\n");
		goto EXIT_DEINIT;
	}

	int readSize;
	if (reader)
		readSize = reader->ReadData(buf, SIZE_2M);

	if (readSize <= 0)
		goto EXIT_DEINIT;

	hResult = sender->Transfer(buf, readSize, 10);
	if (FAILED(hResult))
		goto EXIT_DEINIT;

	Logger * logger = Logger::GetLogger(L"umx");
	
	bool txLogEnabled = true;

	logger->Log(LOG_INFO, L"Start transmitting signal...\n");

	while(!CheckStatus())
	{
		::ShortSleep(100);
		
		hResult = sender->Transmit(txLogEnabled);

		if (txLogEnabled)
		{
			if (hResult == S_OK)
				logger->Log(LOG_INFO, L"Repeated transmission-related function calls will not be logged.\n");
			txLogEnabled = false;
		}

		if (FAILED(hResult))
			break;
	}

	logger->Log(LOG_INFO, L"End transmitting signal.\n");

EXIT_DEINIT:
	if (buf)
		delete buf;
	sender->Deinit();

EXIT:

	::SoraUmxDeinit(Radio::Current());
	if (sender)
		delete sender;
	return;
	//::SendLoop(this, reader, radio);
}
Example #7
0
	ScopeLog::~ScopeLog()
	{
		logger.Log(Debug, _T("Leaving %s"), _name);
		--IndentLevel;
	}
Example #8
0
	void ScopeLog::Initialize(LPCSTR name)
	{
		_name = (LPCTSTR) name;
		++IndentLevel;
		logger.Log(Debug, _T("Entering %S"), _name);
	}
static void InitDriveSubsystemConfiguration()
{
    ConfigMgr *configMgr = ConfigInstanceMgr::getInstance();

    if (!Drive_Params_Inited) {
    	X_Tolerance_Min = configMgr->getDoubleVal(ConfigKeys::Drive_XToleranceMin,X_TOLERANCE_MIN_DEFAULT);

    	X_Tolerance_Max = configMgr->getDoubleVal(ConfigKeys::Drive_XToleranceMax,X_TOLERANCE_MAX_DEFAULT);

    	Y_Tolerance_Min = configMgr->getDoubleVal(ConfigKeys::Drive_YToleranceMin,Y_TOLERANCE_MIN_DEFAULT);

    	Y_Tolerance_Max = configMgr->getDoubleVal(ConfigKeys::Drive_YToleranceMax,Y_TOLERANCE_MAX_DEFAULT);

    	Twist_Tolerance_Min = configMgr->getDoubleVal(ConfigKeys::Drive_TwistToleranceMin,TWIST_TOLERANCE_MIN_DEFAULT);

    	Twist_Tolerance_Max = configMgr->getDoubleVal(ConfigKeys::Drive_TwistToleranceMax,TWIST_TOLERANCE_MAX_DEFAULT);

    	Twist_Scale_Factor = configMgr->getDoubleVal(ConfigKeys::Drive_TwistScaleFactor,TWIST_SCALE_FACTOR_DEFAULT);

    	X_Scale_Factor = configMgr->getDoubleVal(ConfigKeys::Drive_XScaleFactor,X_Scale_Factor_Default);

    	Y_Scale_Factor = configMgr->getDoubleVal(ConfigKeys::Drive_YScaleFactor,Y_Scale_Factor_Default);

    	Slow_Down_Scaling_Factor = configMgr->getDoubleVal(ConfigKeys::Drive_SlowDownScaleFactor,Slow_Down_Scaling_Factor_Default);

    	WheelDiameterInInches = configMgr->getDoubleVal(ConfigKeys::Drive_WheelDiameterInInchesKey, WHEEL_DIAMETER_IN_INCHES_DEFAULT);
    	WheelCircumference = M_PI * WheelDiameterInInches;

    	CountsPerShaftRotation = configMgr->getDoubleVal(ConfigKeys::Drive_CountsPerShaftRotationKey, COUNTS_PER_SHAFT_ROTATION_DEFAULT);

		AutoRotateMaxSpeed = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoRotateMaxSpeedKey, AUTO_ROTATE_MAX_SPEED_DEFAULT));

		AutoRotateSlowDownThreshold = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoRotateSlowDownThresholdKey, AUTO_ROTATE_SLOW_DOWN_THRESHOLD_DEFAULT));

		AngleDecimalPlacesPrecision = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AngleDecimalPlacesPrecisionKey, ANGLE_DECIMAL_PLACES_PRECISION_DEFAULT));

		AutoRotate_TargetAngle_Epsilon = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoRotateTargetAngleEpsilonKey, AUTO_ROTATE_TARGET_ANGLE_EPSILON_DEFAULT));

		AutoDriveUseOneMotorForDistanceDrive = configMgr->getBoolVal(ConfigKeys::Drive_AutoDriveUseOneMotorForDistanceDriveKey, AUTO_DRIVE_USE_ONE_MOTOR_FOR_DISTANCE_DRIVE_DEFAULT);

		AutoDriveForwardBackHeadingSpeedScaleFactor = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveFowardBackHeadingSpeedScaleFactorKey, AUTO_DRIVE_FORWARD_BACK_HEADING_SPEED_SCALE_FACTOR_DEFAULT));

		AutoDriveLeftRightHeadingSpeedScaleFactor = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveLeftRightHeadingSpeedScaleFactorKey, AUTO_DRIVE_LEFT_RIGHT_HEADING_SPEED_SCALE_FACTOR_DEFAULT));

		AutoDriveSlowDownThresholdInInches = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveSlowDownThresholdInInchesKey, AUTO_DRIVE_SLOW_DOWN_THRESHOLD_IN_INCHES_DEFAULT));

		AutoDriveSlowDownThresholdInShaftRotations = DistanceToShaftRotationCount(AutoDriveSlowDownThresholdInInches, DriveForward);

		AutoDriveStartSlowingDistancePercentage = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveStartSlowingDistancePercentageKey, AUTO_DRIVE_START_SLOWING_DISTANCE_PERCENTAGE_DEFAULT);

		AutoDriveTargetDistanceEpsilonInInches = static_cast<float>(configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveTargetDistanceEpsilonInInchesKey, AUTO_DRIVE_TARGET_DISTANCE_EPSILON_IN_INCHES_DEFAULT));

		AutoDriveTargetDistanceEpsilonInCounts = DistanceToShaftRotationCount(AutoDriveTargetDistanceEpsilonInInches, DriveForward);

		AutoDriveFrontLeftMotorSpeed = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveFrontLeftSpeedKey, AUTO_DRIVE_FRONT_LEFT_SPEED_DEFAULT);

		AutoDriveFrontRightMotorSpeed = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveFrontRightSpeedKey, AUTO_DRIVE_FRONT_RIGHT_SPEED_DEFAULT);

		AutoDriveBackLeftMotorSpeed = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveBackLeftSpeedKey, AUTO_DRIVE_BACK_LEFT_SPEED_DEFAULT);

		AutoDriveBackRightMotorSpeed = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveBackRightSpeedKey, AUTO_DRIVE_BACK_RIGHT_SPEED_DEFAULT);

		AutoDriveMinSlowDownSpeedPercentage = configMgr->getDoubleVal(ConfigKeys::Drive_AutoDriveMinSlowDownSpeedPercentageKey, AUTO_DRIVE_MIN_SLOW_DOWN_SPEED_PERCENTAGE_DEFAULT);

		Logger* logger = Logger::GetInstance();

		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: X Tolerance min = %f, max = %f\n", X_Tolerance_Min, X_Tolerance_Max);
		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: Y Tolerance min = %f, max = %f\n", Y_Tolerance_Min, Y_Tolerance_Max);
		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: Twist Tolerance min = %f, max = %f, Scale factor = %f \n", Twist_Tolerance_Min, Twist_Tolerance_Max, Twist_Scale_Factor);

		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: Wheel Diameter = %d inches\n", WheelDiameterInInches);
		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: Counts Per Shaft Rotation = %d inches\n", CountsPerShaftRotation);

		logger->Log(DriveSubsystemLogId,Logger::kINFO, "DriveSubsystem: Wheel Diameter = %d inches, Circumference = %g\n",
      				WheelDiameterInInches, WheelCircumference);

		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoRotateMaxSpeed = %f\n", AutoRotateMaxSpeed);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoRotateAnglePrecision = %f\n", AngleDecimalPlacesPrecision);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoRotateTargetAngleEpsilon = %f\n", AutoRotate_TargetAngle_Epsilon);

		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveForwardBackHeadingSpeedScaleFactor = %f\n", AutoDriveForwardBackHeadingSpeedScaleFactor);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveLeftRightHeadingMaxSpeed = %f\n", AutoDriveLeftRightHeadingSpeedScaleFactor);

		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveSlowDownThresholdInInches = %f\n", AutoDriveSlowDownThresholdInInches);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveSlowDownThresholdInShaftRotations = %f\n", AutoDriveSlowDownThresholdInShaftRotations);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveTargetDistanceEpsilonInInches = %f\n", AutoDriveTargetDistanceEpsilonInInches);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveTargetDistanceEpsilonInCounts = %f\n", AutoDriveTargetDistanceEpsilonInCounts);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: AutoDriveMinSlowDownSpeedPercentage = %g\n", AutoDriveMinSlowDownSpeedPercentage);

		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: SlowDownScalingFactor = %f\n", Slow_Down_Scaling_Factor);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: XScalingFactor = %f\n", X_Scale_Factor);
		logger->Log(DriveSubsystemLogId, Logger::kINFO, "DriveSubsystem: YScalingFactor = %f\n", Y_Scale_Factor);

      	Drive_Params_Inited = true;
    }
}