// Handle the events we wish to log // Increases priority of messages, if this is a debug build. // Note: in /etc/rsyslog.conf, if this default line: // *.*;auth,authpriv.none -/var/log/syslog // is changed to // *.info;auth,authpriv.none -/var/log/syslog // then messages with priority of LOG_DEBUG will not be stored // that line would need to be restored to its default // in order to see items logged by this method in a release build void Logger::Callback(EventType eventType, const EventData& data) { int priority = LOG_DEBUG; #ifdef DEBUG priority = LOG_INFO; #endif PrinterStatus ps; switch(eventType) { case PrinterStatusUpdate: ps = data.Get<PrinterStatus>(); // only log state entering and leaving if (ps._change == Entering || ps._change == Leaving) { const char* substate = ps._UISubState == NoUISubState ? "" : SUBSTATE_NAME(ps._UISubState); syslog(priority, LOG_STATUS_FORMAT, ps._change == Entering ? ENTERING : LEAVING, STATE_NAME(ps._state), substate); } break; case MotorInterrupt: syslog(priority, LOG_MOTOR_EVENT, data.Get<unsigned char>()); break; case ButtonInterrupt: syslog(priority, LOG_BUTTON_EVENT, data.Get<unsigned char>()); break; case DoorInterrupt: syslog(priority, LOG_DOOR_EVENT, data.Get<char>()); break; case Keyboard: syslog(priority, LOG_KEYBOARD_INPUT, data.Get<std::string>().c_str()); break; case UICommand: syslog(priority, LOG_UI_COMMAND, data.Get<std::string>().c_str()); break; default: LOGGER.LogError(LOG_WARNING, errno, ERR_MSG(UnexpectedEvent), eventType); break; } }
// Updates the front panel displays, based on printer status void FrontPanel::ShowStatus(const PrinterStatus& ps) { if (ps._change != Leaving) { // display the screen for this state and sub-state PrinterStatusKey key = PS_KEY(ps._state, ps._UISubState); if (ps._state == PrintingLayerState) { // force the display of the remaining print time // whenever we enter or re-enter the PrintingLayer state // e.g. after door closed or resuming from pause _forceDisplay = true; } if (_screens.count(key) < 1) { std::cout << "Unknown screen for state: " << STATE_NAME(ps._state) << ", substate: " << SUBSTATE_NAME(ps._UISubState) << std::endl; key = UNKNOWN_SCREEN_KEY; } Screen* pScreen = _screens[key]; if (pScreen != NULL) { // make sure a display thread isn't already running AwaitThreadComplete(); // display the selected screen in a separate thread, to // avoid blocking here FrontPanelScreen* pFPS = new FrontPanelScreen(this, ps, pScreen); pthread_create(&_showScreenThread, NULL, &ThreadHelper, pFPS); } } }