Beispiel #1
0
int main()
{
  using namespace logs;
  
  Logger logger;
  logger.PushSink(std::make_shared<StreamSink>(Stream(&std::clog, false)));
  
  std::ofstream* log = new std::ofstream("/tmp/log.log");
  logger.PushSink(std::make_shared<StreamSink>(Stream(log, true)));
//  logger.PushSink(std::make_shared<db::LogSink>("somecol"));
  
  logger.Write("message", QuoteOn('\''), "this is a message", "kbytes", 1243432, QuoteOff(), "size", 100.20);
}
Beispiel #2
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND   - process the application menu
//  WM_PAINT   - Paint the main window
//  WM_DESTROY   - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   int wmId, wmEvent;
   PAINTSTRUCT ps;
   HDC hdc;
   float xPos, yPos;
   switch (message)
   {
   case WM_CREATE:
	   
        hdc = GetDC(hWnd);

		if (!renderer.Init(hWnd, hdc))
		{
			ShowCursor(true);
			//MessageBoxA(0,(char*)glGetString(GL_VERSION), "OPENGL VERSION",0);
			logger.Write("Unable to create Rendering Context - Error Initializing Renderer\n");
			MessageBoxA(0,"Unable to create Rendering Context", "Error Initializing Renderer",0);
			PostQuitMessage(0);
		}
		ShowCursor(false);
		renderer.SetupScene();
		break;
   case WM_MOUSEMOVE:
      xPos = LOWORD(lParam);
      yPos = HIWORD(lParam);
	  
      if (fabs(xPos - 100.0f) < 0.01f && fabs(yPos - 100.0f) < 0.01f) { // prevent inf loop. probably more efficient way to handle this.
         break;
      }
      game.MouseMove(xPos, yPos);
      
	  SetCursorPos(100, 100); // so we never hit a screen edge.
      break;
   case WM_ENTERSIZEMOVE:
      //game.Pause();
      resizing  = true;
      break;

   // WM_EXITSIZEMOVE is sent when the user releases the resize bars.
   // Here we reset everything based on the new window dimensions.
   case WM_EXITSIZEMOVE:
      //game.Resume();
      resizing  = false;      
     // game.OnResize(screenWidth, screenHeight);
      return 0;
   case WM_ACTIVATE:     
      if (LOWORD(wParam) == WA_INACTIVE) {
        // game.Pause();         
      } else {
        // game.Resume();         
      }
      break;
   case WM_KEYDOWN:
      switch (wParam) {
		  // Short VK_A..VK_Z, etc.
      case VK_ESCAPE:
         ShowCursor(true);
         PostQuitMessage(0);
         break;
      case 'W':
      case 'w':         
			game.UpdateMovement(1.0f, 0.0f);
         break;
      case 'S':
      case 's':
			game.UpdateMovement(-1.0f, 0.0f);
         break;
	  case 'A':
      case 'a':
			game.UpdateMovement(0.0f, 1.0f);
         break;
		  
	  case 'D':
      case 'd':
			game.UpdateMovement(0.0f, -1.0f);
         break;
      case VK_ADD:
        // game.SetSpeed(game.GetSpeed() * 2);
         break;
      case VK_SUBTRACT:
      //   if (game.GetSpeed() > 1) {
      //      game.SetSpeed(game.GetSpeed() / 2);
      //   }
         break;
      }
      
      break;
   case WM_COMMAND:
      wmId    = LOWORD(wParam);
      wmEvent = HIWORD(wParam);
      // Parse the menu selections:
      switch (wmId)
      {
		  /*
      case IDM_ABOUT:
         DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
         break;
      case IDM_EXIT:
         DestroyWindow(hWnd);
         break;*/
      default:
         return DefWindowProc(hWnd, message, wParam, lParam);
      }
      break;
   case WM_PAINT:
      hdc = BeginPaint(hWnd, &ps);
      EndPaint(hWnd, &ps);
      break;
   case WM_DESTROY:
#ifdef GL
	   //wglMakeCurrent (hdc, NULL);
	   //wglDeleteContext(ourOpenGLRenderingContext);
#endif
      ShowCursor(true);
      PostQuitMessage(0);
      break;
   case WM_SIZE:
      // Save the new client area dimensions.
      screenWidth  = LOWORD(lParam);
      screenHeight = HIWORD(lParam);
           
      ShowCursor(true);
	  renderer.ReshapeWindow(screenWidth, screenHeight);

      /*
      if( wParam == SIZE_MINIMIZED )
      {
         game.Pause();
      
      }
      else if( wParam == SIZE_MAXIMIZED )
      {
         game.OnResize(screenWidth, screenHeight);
         game.Resume();
      }
      else if( wParam == SIZE_RESTORED )
      {
         game.OnResize(screenWidth, screenHeight);
         game.Resume();
      }
      else if( resizing )
      {
               // If user is dragging the resize bars, we do not resize 
               // the buffers here because as the user continuously 
               // drags the resize bars, a stream of WM_SIZE messages are
               // sent to the window, and it would be pointless (and slow)
               // to resize for each WM_SIZE message received from dragging
               // the resize bars.  So instead, we reset after the user is 
               // done resizing the window and releases the resize bars, which 
               // sends a WM_EXITSIZEMOVE message.
            }
      else // API call such as SetWindowPos or mSwapChain->SetFullscreenState.
      {
         game.OnResize(screenWidth, screenHeight);
      }*/
      break;
   default:
      return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
Beispiel #3
0
void APIENTRY glDebug(GLenum source​, GLenum type​, GLuint id​, GLenum severity​, GLsizei length​, const GLchar* message​, void* userParam​)
{
	m_logger.Write((char *)message​);
}