static bool LoadLanguageFile(const TCHAR *path) { #ifdef HAVE_NATIVE_GETTEXT /* not supported on UNIX */ return false; #else /* !HAVE_NATIVE_GETTEXT */ LogFormat(_T("Language: loading file '%s'"), path); delete mo_loader; mo_loader = new MOLoader(path); if (mo_loader->error()) { LogFormat(_T("Language: could not load file '%s'"), path); delete mo_loader; mo_loader = NULL; return false; } LogFormat(_T("Loaded translations from file '%s'"), path); mo_file = &mo_loader->get(); return true; #endif /* !HAVE_NATIVE_GETTEXT */ }
void Display::LoadOrientation(VerboseOperationEnvironment &env) { if (!Display::RotateSupported()) return; Display::RotateInitialize(); DisplayOrientation orientation = CommonInterface::GetUISettings().display.orientation; #ifdef KOBO /* on the Kobo, the display orientation must be loaded explicitly (portrait), because the hardware default is landscape */ #else if (orientation == DisplayOrientation::DEFAULT) return; #endif if (!Display::Rotate(orientation)) { LogFormat("Display rotation failed"); return; } #ifdef KOBO event_queue->SetMouseRotation(orientation); #endif LogFormat("Display rotated"); CommonInterface::main_window->Initialise(); /* force the progress dialog to update its layout */ env.UpdateLayout(); }
bool ALSAPCMPlayer::TryRecoverFromError(snd_pcm_t &alsa_handle, int error) { assert(error < 0); if (-EPIPE == error) LogFormat("ALSA PCM buffer underrun"); else if ((-EINTR == error) || (-ESTRPIPE == error)) LogFormat("ALSA PCM error: %s - trying to recover", snd_strerror(error)); else { // snd_pcm_recover() can only handle EPIPE, EINTR and ESTRPIPE LogFormat("Unrecoverable ALSA PCM error: %s", snd_strerror(error)); return false; } int recover_error = snd_pcm_recover(&alsa_handle, error, 1); if (0 == recover_error) { LogFormat("ALSA PCM successfully recovered"); return true; } else { LogFormat("snd_pcm_recover(0x%p, %d, 1) failed: %d - %s", &alsa_handle, error, recover_error, snd_strerror(recover_error)); return false; } }
bool ALSAPCMPlayer::WriteFrames(snd_pcm_t &alsa_handle, int16_t *buffer, size_t n, bool try_recover_on_error) { assert(n > 0); assert(nullptr != buffer); snd_pcm_sframes_t write_ret = snd_pcm_writei(&alsa_handle, buffer, static_cast<snd_pcm_uframes_t>(n)); if (write_ret < static_cast<snd_pcm_sframes_t>(n)) { if (write_ret < 0) { if (try_recover_on_error) { return TryRecoverFromError(alsa_handle, static_cast<int>(write_ret)); } else { LogFormat("snd_pcm_writei(0x%p, 0x%p, %u) failed: %d - %s", &alsa_handle, buffer, static_cast<unsigned>(n), static_cast<int>(write_ret), snd_strerror(static_cast<int>(write_ret))); return false; } } else { // Never observed this case. Should not happen? Cannot happen? LogFormat("Only %u of %u ALSA PCM frames written", static_cast<unsigned>(write_ret), static_cast<unsigned>(n)); } return false; } assert(write_ret == static_cast<snd_pcm_sframes_t>(n)); return true; }
void CheckLogCat(IOThread &io_thread) { LogFormat("Launching logcat"); FileDescriptor r, w; if (!FileDescriptor::CreatePipe(r, w)) return; pid_t pid = fork(); if (pid == 0) { /* in the child process */ w.Duplicate(1); execl("/system/bin/logcat", "logcat", "-v", "threadtime", "-d", "-t", "1000", NULL); _exit(EXIT_FAILURE); } if (pid < 0) { LogFormat("Launching logcat has failed: %s", strerror(errno)); return; } log_cat_reader = new LogCatReader(io_thread, std::move(r), pid); }
static bool ReadResourceLanguageFile(const TCHAR *resource) { if (!FindLanguage(resource)) /* refuse to load resources which are not in the language table */ return false; LogFormat(_T("Language: loading resource '%s'"), resource); // Load resource ResourceLoader::Data data = ResourceLoader::Load(resource, _T("MO")); if (data.first == NULL) { LogFormat(_T("Language: resource '%s' not found"), resource); return false; } // Load MO file from resource delete mo_loader; mo_loader = new MOLoader(data.first, data.second); if (mo_loader->error()) { LogFormat(_T("Language: could not load resource '%s'"), resource); delete mo_loader; mo_loader = NULL; return false; } LogFormat(_T("Loaded translations from resource '%s'"), resource); mo_file = &mo_loader->get(); return true; }
Port::WaitResult DumpPort::WaitRead(unsigned timeout_ms) { LogFormat("WaitRead %u", timeout_ms); Port::WaitResult result = port->WaitRead(timeout_ms); LogFormat("WaitRead %u = %d", timeout_ms, (int)result); return result; }
size_t DumpPort::Write(const void *data, size_t length) { LogFormat("Write(%u)", (unsigned)length); size_t nbytes = port->Write(data, length); LogFormat("Write(%u)=%u", (unsigned)length, (unsigned)nbytes); HexDump("W ", data, nbytes); return nbytes; }
void StartupLogFreeRamAndStorage() { #ifdef HAVE_MEM_INFO unsigned long freeram = SystemFreeRAM() / 1024; LogFormat("Free ram %lu KB", freeram); #endif unsigned long freestorage = FindFreeSpace(GetPrimaryDataPath()); LogFormat("Free storage %lu KB", freestorage); }
int DumpPort::Read(void *buffer, size_t size) { LogFormat("Read(%u)", (unsigned)size); int nbytes = port->Read(buffer, size); LogFormat("Read(%u)=%d", (unsigned)size, nbytes); if (nbytes > 0) HexDump("R ", buffer, nbytes); return nbytes; }
Port::WaitResult DumpPort::WaitRead(unsigned timeout_ms) { const bool enabled = CheckEnabled(); if (enabled) LogFormat("WaitRead %u", timeout_ms); Port::WaitResult result = port->WaitRead(timeout_ms); if (enabled) LogFormat("WaitRead %u = %d", timeout_ms, (int)result); return result; }
void devStartup() { LogFormat("Register serial devices"); const SystemSettings &settings = CommonInterface::GetSystemSettings(); bool none_available = true; for (unsigned i = 0; i < NUMDEV; ++i) { DeviceDescriptor &device = *device_list[i]; const DeviceConfig &config = settings.devices[i]; if (!config.IsAvailable()) { device.ClearConfig(); continue; } none_available = false; bool overlap = false; for (unsigned j = 0; j < i; ++j) if (DeviceConfigOverlaps(config, device_list[j]->GetConfig())) overlap = true; if (overlap) { device.ClearConfig(); continue; } device.SetConfig(config); devInitOne(*device_list[i]); } if (none_available) { #ifdef ANDROID /* fall back to built-in GPS when no configured device is available on this platform */ LogFormat("Falling back to built-in GPS"); DeviceConfig config; config.Clear(); config.port_type = DeviceConfig::PortType::INTERNAL; DeviceDescriptor &device = *device_list[0]; device.SetConfig(config); devInitOne(device); #endif } }
/** * Reads the selected LanguageFile into the cache */ void ReadLanguageFile() { #ifndef HAVE_NATIVE_GETTEXT CloseLanguageFile(); LogFormat("Loading language file"); TCHAR buffer[MAX_PATH], second_buffer[MAX_PATH]; const TCHAR *value = Profile::GetPath(ProfileKeys::LanguageFile, buffer) ? buffer : _T(""); if (StringIsEqual(value, _T("none"))) return; if (StringIsEmpty(value) || StringIsEqual(value, _T("auto"))) { AutoDetectLanguage(); return; } const TCHAR *base = BaseName(value); if (base == NULL) base = value; if (base == value) { LocalPath(second_buffer, value); value = second_buffer; } if (!LoadLanguageFile(value) && !ReadResourceLanguageFile(base)) AutoDetectLanguage(); #endif }
EXPORT_C void CImMobilityLogger::LogText(TInt /*aFilePos*/, const TDesC8& /*aText*/) #endif //__IM_MOBILITY_LOGGING { #ifdef __IM_MOBILITY_LOGGING LogFormat(aFilePos, KTxtFormatText, &aText); #endif //__IM_MOBILITY_LOGGING }
bool WaypointGlue::SaveWaypoints(const Waypoints &way_points) { const auto path = LocalPath(_T("user.cup")); TextWriter writer(path); if (!writer.IsOpen()) { LogFormat(_T("Waypoint file '%s' can not be written"), path.c_str()); return false; } WriteCup(writer, way_points, WaypointOrigin::USER); LogFormat(_T("Waypoint file '%s' saved"), path.c_str()); return true; }
void LoggerImpl::StopLogger(const NMEAInfo &gps_info) { // Logger can't be switched off if already off -> cancel if (writer == nullptr) return; writer->Flush(); if (!simulator) writer->Sign(); writer->Flush(); LogFormat(_T("Logger stopped: %s"), filename.c_str()); // Logger off delete writer; writer = nullptr; // Make space for logger file, if unsuccessful -> cancel if (gps_info.gps.real && gps_info.date_time_utc.IsDatePlausible()) IGCFileCleanup(gps_info.date_time_utc.year); pre_takeoff_buffer.clear(); }
bool WaypointGlue::LoadWaypoints(Waypoints &way_points, const RasterTerrain *terrain, OperationEnvironment &operation) { LogFormat("ReadWaypoints"); operation.SetText(_("Loading Waypoints...")); bool found = false; // Delete old waypoints way_points.Clear(); TCHAR path[MAX_PATH]; LoadWaypointFile(way_points, LocalPath(path, _T("user.cup")), WaypointFileType::SEEYOU, WaypointOrigin::USER, terrain, operation); // ### FIRST FILE ### if (Profile::GetPath(ProfileKeys::WaypointFile, path)) found |= LoadWaypointFile(way_points, path, WaypointOrigin::PRIMARY, terrain, operation); // ### SECOND FILE ### if (Profile::GetPath(ProfileKeys::AdditionalWaypointFile, path)) found |= LoadWaypointFile(way_points, path, WaypointOrigin::ADDITIONAL, terrain, operation); // ### WATCHED WAYPOINT/THIRD FILE ### if (Profile::GetPath(ProfileKeys::WatchedWaypointFile, path)) found |= LoadWaypointFile(way_points, path, WaypointOrigin::WATCHED, terrain, operation); // ### MAP/FOURTH FILE ### // If no waypoint file found yet if (!found) { auto dir = OpenMapFile(); if (dir != nullptr) { found |= LoadWaypointFile(way_points, dir, "waypoints.xcw", WaypointFileType::WINPILOT, WaypointOrigin::MAP, terrain, operation); found |= LoadWaypointFile(way_points, dir, "waypoints.cup", WaypointFileType::SEEYOU, WaypointOrigin::MAP, terrain, operation); zzip_dir_close(dir); } } // Optimise the waypoint list after attaching new waypoints way_points.Optimise(); // Return whether waypoints have been loaded into the waypoint list return found; }
void ReadAssetNumber() { #ifdef _WIN32_WCE if (ReadCompaqID()) { LogFormat(_T("Asset ID: %s (compaq)"), asset_number); } else if (ReadUUID()) { LogFormat(_T("Asset ID: %s (uuid)"), asset_number); } else { #endif _tcscpy(asset_number, _T("AAA")); #ifdef _WIN32_WCE LogFormat(_T("Asset ID: %s (fallback)"), asset_number); } #endif }
void Profile::Load() { LogFormat("Loading profiles"); LoadFile(startProfileFile); SetModified(false); }
size_t DumpPort::Write(const void *data, size_t length) { const bool enabled = CheckEnabled(); if (enabled) LogFormat("Write(%u)", (unsigned)length); size_t nbytes = port->Write(data, length); if (enabled) { LogFormat("Write(%u)=%u", (unsigned)length, (unsigned)nbytes); HexDump("W ", data, nbytes); } return nbytes; }
static inline void HexDumpLine(const char *prefix, unsigned offset, const uint8_t *data, size_t length) { NarrowString<128> line; line.clear(); for (size_t i = 0; i < length; ++i) { if ((i & 0x7) == 0) line += " "; line.AppendFormat(" %02x", data[i]); } for (size_t i = length; i < 0x10; ++i) { if ((i & 0x7) == 0) line += " "; line += " "; } line += " "; for (size_t i = 0; i < length; ++i) { if ((i & 0x7) == 0) line += " "; char byte[2]; byte[0] = IsPrintable(data[i]) ? (char)data[i] : '.'; byte[1] = '\0'; line += byte; } LogFormat("%s%04x%s", prefix, offset, line.c_str()); }
void DumpPort::Flush() { if (CheckEnabled()) LogFormat("Flush"); port->Flush(); }
bool DumpPort::Drain() { if (CheckEnabled()) LogFormat("Drain"); return port->Drain(); }
void LogCatReader::Wait(pid_t pid) { if (pid <= 0) return; int status; pid_t pid2 = ::waitpid(pid, &status, 0); if (pid2 <= 0) return; if (WIFSIGNALED(status)) LogFormat("logcat was killed by signal %d", WTERMSIG(status)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) LogFormat("logcat has failed"); }
int DumpPort::Read(void *buffer, size_t size) { const bool enabled = CheckEnabled(); if (enabled) LogFormat("Read(%u)", (unsigned)size); int nbytes = port->Read(buffer, size); if (enabled) { LogFormat("Read(%u)=%d", (unsigned)size, nbytes); if (nbytes > 0) HexDump("R ", buffer, nbytes); } return nbytes; }
bool DumpPort::SetBaudrate(unsigned baud_rate) { if (CheckEnabled()) LogFormat("SetBaudrate %u", baud_rate); return port->SetBaudrate(baud_rate); }
static bool ParseAirspaceFile(AirspaceParser &parser, Path path, OperationEnvironment &operation) try { FileLineReader reader(path, Charset::AUTO); if (!parser.Parse(reader, operation)) { LogFormat(_T("Failed to parse airspace file: %s"), path.c_str()); return false; } return true; } catch (const std::runtime_error &e) { LogFormat(_T("Failed to parse airspace file: %s"), path.c_str()); LogError(e); return false; }
bool DumpPort::StartRxThread() { if (CheckEnabled()) LogFormat("StartRxThread"); return port->StartRxThread(); }
//-------------------------------------------------------------------------- void VeLog::LogFormat(Type eType, const VeChar8* pcTag, const VeChar8* pcFormat, ...) noexcept { va_list kArgs; va_start(kArgs, pcFormat); LogFormat(eType, pcTag, pcFormat, kArgs); va_end(kArgs); }
void Profile::SaveFile(const TCHAR *szFile) { if (StringIsEmpty(szFile)) return; LogFormat(_T("Saving profile to %s"), szFile); SaveFile(map, szFile); }