xapi args_summarize() { enter; char space[512]; int x; logs(L_ARGS | L_PARAMS, "--------------------------------------------------------------------------------"); // log execution parameters under PARAMS logf(L_PARAMS , "%11sprocessors =%ld" , "" , g_args.procs); #if DEBUG || DEVEL logf(L_ARGS | L_PARAMS , " %s ( %c ) mode-backtrace =%s", g_args.mode_backtrace == DEFAULT_MODE_BACKTRACE ? " " : "*", ' ', MODE_STR(g_args.mode_backtrace)); #endif if(g_args.concurrency == 0) snprintf(space, sizeof(space) , "%s", "unbounded"); else snprintf(space, sizeof(space) , "%d", g_args.concurrency); logf(L_ARGS | L_PARAMS , " %s ( %c ) concurrency =%s", g_args.concurrency == (int)((float)g_args.procs * 1.2f) ? " " : "*", 'j', space); if(g_args.objectsl == 0) logf(L_ARGS | L_PARAMS , " %s ( %c ) object(s) =", " ", ' '); for(x = 0; x < g_args.objectsl; x++) logf(L_ARGS | L_PARAMS , " %s ( %c ) object(s) =%s", "*", ' ', g_args.objects[x]); logs(L_ARGS | L_PARAMS, "--------------------------------------------------------------------------------"); finally : coda; }
bool Physics::init(){ #ifdef LOOP_DEBUG logs().main.write("START PHYSICS INIT"); #endif #ifdef ODE worldId=dWorldCreate(); #endif #ifdef LOOP_DEBUG logs().main.write("START PHYSICS INIT SCRIPT"); #endif LuaType* luaa=script().add("physics"); LuaType* clua=script().add("gravity",luaa); script().add("x",&gravity.x,clua); script().add("y",&gravity.y,clua); script().add("z",&gravity.z,clua); script().add("collide",&collide,luaa); script().add("trace",luaTrace,luaa); #ifdef LOOP_DEBUG logs().main.write("START PHYSICS INIT END"); #endif return true; }
xapi usage_report() { enter; char space[64]; int fd = -1; int token = 0; if(log_would(L_USAGE)) { // check memory usage fatal(uxopens, &fd, O_RDONLY, "/proc/self/statm"); long pages = 0; if(fd != -1) { fatal(xread, fd, space, sizeof(space), 0); sscanf(space, "%*d %ld", &pages); } fatal(log_start, L_USAGE, &token); logs(0, "usage : mem("); fatal(bytesize_say, pages * g_params.pagesize, log_narrator(&token)); logs(0, ")"); fatal(log_finish, &token); } finally: fatal(log_finish, &token); fatal(ixclose, &fd); coda; }
static inode_t* inode_create (fs_node_type_t type, const char* name_begin, const char* name_end, bd_t bd, size_t size, inode_t* parent) { inode_t* node; if (free_list != 0) { /* Take a node from the free list. */ node = free_list; free_list = node->next_sibling; } else { /* Expand the vector if necessary. */ if (nodes_size == nodes_capacity) { nodes_capacity = nodes_capacity * 2 + 1; nodes = realloc (nodes, nodes_capacity * sizeof (inode_t*)); if (nodes == 0) { snprintf (log_buffer, LOG_BUFFER_SIZE, ERROR "out of memory: %s", lily_error_string (lily_error)); logs (log_buffer); exit (-1); } } /* Create a new node. */ node = malloc (sizeof (inode_t)); if (node == NULL) { snprintf (log_buffer, LOG_BUFFER_SIZE, ERROR "out of memory: %s", lily_error_string (lily_error)); logs (log_buffer); exit (-1); } node->nodeid = nodes_size++; } /* Place the node in the index. */ nodes[node->nodeid] = node; /* Initialize the node. */ node->type = type; size_t name_size = name_end - name_begin; node->name_begin = malloc (name_size); memcpy (node->name_begin, name_begin, name_size); node->name_end = node->name_begin + name_size; node->bd = bd; node->size = size; node->parent = parent; node->first_child = 0; node->next_sibling = 0; return node; }
bool BufferedLoggerMark::enter() { if(_mst.size()>0){ if (crp()) _mst.cr(); logs(Log::ENTER, _mst.as_string()); _mst.reset(); } else { logs(Log::ENTER, "begin\n"); } _depth++; return true; }
int Audio::load(Path file){ // Variables to load into. if(!os().fileExists(file)){ logs().audio.write("[AudioObject] Error, file '"+file.getRelative()+"' doesn't exist"); console().write("audio error: file '"+file.getRelative()+"' doesn't exist"); return -1; } for(int i=0; i<sources.size(); i++){ if(sources[i]->filename==file){ console().write("NOTE: the file "+file.getRelative()+" was already loaded as another audio object. This is not an error, but may not be what was intended"); } } String filetype=file.getExtension(); if(filetype=="wav"){ if(hardware.audio){ return loadWav(file); }else{ return loadFakeWav(file); } }else if(filetype=="ogg"){ #ifdef FEATURE_OGG if(hardware.audio){ #ifdef OGG_STREAM return loadOggStream(file); #else return loadOgg(file); #endif }else{ return loadFakeOgg(file); } #else console().write("audio error: this version of the engine can't open oggs"); return -1; #endif }else{ logs().audio.write("[AudioObject] error: unknown filetype '"+filetype+"' for file '"+file.getRelative()+"'"); console().write("audio error: unknown filetype '"+filetype+"' for file '"+file.getRelative()+"'"); return -1; } }
bool BufferedLoggerMark::leave() { if (_depth > 0) { _depth--; if(_mst.size()>0){ if (crp()) _mst.cr(); logs(Log::LEAVE, _mst.as_string()); _mst.reset(); } else { logs(Log::LEAVE, "done\n"); } return true; } return false; }
// process a single acquisition int RtDataViewer::process(ACE_Message_Block *mb) { ACE_TRACE(("RtDataViewer::process")); RtStreamMessage *msg = (RtStreamMessage*) mb->rd_ptr(); // get the current time unsigned int time = msg->getCurrentData()->getDataID().getTimePoint(); // debug getDataStore().getAvailableData(); RtDataID id; // find all data requested for(vector<string>::iterator i = dataIds.begin(); i != dataIds.end(); i++) { id.setFromString(*i); if(id.getTimePoint() != DATAID_NUM_UNSET_VALUE && id.getTimePoint() != DATAID_NUM_WILDCARD_VALUE) { id.setTimePoint(time); } cout << "RtDataViewer::process: searching for " << id << " from " << *i << endl; // find the data with the right ID RtData *dat = getDataStore().getData(id); if(dat == NULL) { cout << "RtDataViewer::process: could not find " << id << endl; if(logOutput) { stringstream logs(""); logs << "RtDataViewer::process: could not find " << id << endl; log(logs); } } else { cout << "RtDataViewer::process: found " << dat->getDataID() << endl; if(logOutput) { stringstream logs(""); logs << "RtDataViewer::process: found " << dat->getDataID() << endl; log(logs); } } } return 0; }
pid_t get_daemon_pid(const char *pid_path) { FILE *f; pid_t pid; /* pids are only 15 bits but 4294967296 * (32 bits in case of a new system use it) is on 10 bytes */ if ((f = fopen(pid_path, "rb")) != NULL) { char pid_ascii[PID_ASCII_SIZE]; (void)fgets(pid_ascii, PID_ASCII_SIZE, f); (void)fclose(f); pid = atoi(pid_ascii); } else { logs(LOG_CRIT, "Can't open %s: %s\n", pid_path, strerror(errno)); return -1; } return pid; } /* GetDaemonPid */
/** Logs a formatted warning message to a log file. * \param[in] pszStr - format string for the given parameters */ void log_file::logw(const tchar_t* pszStr) { if (m_iLogLevel > level_warning) return; logs(level_warning, false, pszStr); }
//-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- void tLogDatabaseExport::ExportFile( const QString& filepath ) { tFile exportFile( filepath ); if ( !exportFile.open( QIODevice::WriteOnly ) ) { m_Result = eExportResult_Error; m_ErrorCode = exportFile.error(); m_ErrorMessage = exportFile.errorString(); return; } // We need to open all the log files and write them in to the user selected file // in the correct order. QDir dir(tPath::HistoryFile()); QStringList filter; filter << "Nmea0183log???.log"; QStringList logs(dir.entryList(filter)); // Work out what the resulting file size will be so we can emit a % signal // during the export quint64 totalExportSize = 0; quint64 exportedSize = 0; foreach (QString log, logs) { QFileInfo fileInfo(dir.filePath(log)); totalExportSize += fileInfo.size(); }
/** Logs a formatted debug message to a log file. * \param[in] pszStr - format string for the given parameters */ void log_file::logd(const tchar_t* pszStr) { if (m_iLogLevel > level_debug) return; logs(level_debug, false, pszStr); }
/** Logs a formatted informational message to a log file. * \param[in] pszStr - format string for the given parameters */ void log_file::logi(const tchar_t* pszStr) { if (m_iLogLevel > level_info) return; logs(level_info, false, pszStr); }
bool SIMoutput::savePoints (const Vector& psol, double time, int step) const { if (step < 1 || psol.empty()) return true; myProblem->initResultPoints(time); for (size_t i = 0; i < myPoints.size(); i++) { if (myPoints[i].first.empty()) continue; bool havePoints = false; for (size_t j = 0; i < myPoints[i].second.size() && !havePoints; j++) havePoints = this->getLocalPatchIndex(myPoints[i].second[j].patch) > 0; if (havePoints) { std::ofstream fs(myPoints[i].first.c_str(), step == 1 ? std::ios::out : std::ios::app); utl::LogStream logs(fs); if (!this->dumpResults(psol,time,logs,myPoints[i].second,false,3)) return false; } } return true; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); #define RAD(x) (((x)*M_PI)/180.) gluLookAt(-sinf(RAD(rotx))*5.5,transy,cosf(RAD(rotx))*5.5, 0.,0.,0., 0.,1.,0.); glTranslatef(0.f, 0.f, transx*10.f); /* floor */ glColor4f(0.f,.2f,0.f,1.f); glBegin(GL_POLYGON); glVertex3f(-4.0, -1.0, -4.0); glVertex3f( 4.0, -1.0, -4.0); glVertex3f( 4.0, -1.0, 4.0); glVertex3f(-4.0, -1.0, 4.0); glEnd(); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glColor3f(.1f,.1f,.1f); glPushMatrix(); glTranslatef(-1.f, -1.+.2f, -1.5f); glScalef(.2f,.2f, .2f); logs(); glDisable(GL_LIGHTING); glPopMatrix(); glPushMatrix(); glTranslatef(-1.f, -1.f+.2f, -1.5f); calcMatrix(); draw_smoke(smoke); glPopMatrix(); glPushMatrix(); glTranslatef(-1.f, -.25f, -1.5f); calcMatrix(); glScalef(1.f,1.f,1.); if (texture) { glBindTexture(GL_TEXTURE_2D, the_texture+1); glEnable(GL_TEXTURE_2D); } glColor4f(intensity, intensity, intensity, opacity); glRotatef(rot, 0., 0., 1.); glDepthMask(0); glBegin(GL_POLYGON); glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, -1.0); glTexCoord2f(1.0, 0.0); glVertex2f(1.0, -1.0); glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0); glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, 1.0); glEnd(); glDepthMask(1); glPopMatrix(); glDisable(GL_TEXTURE_2D); glutSwapBuffers(); }
int is_myself_running(const char *pid_path) { int retVal = -1; struct stat fStatBuf; retVal = stat(pid_path, &fStatBuf); if(0 == retVal) { pid_t pid = -1; pid = get_daemon_pid(pid_path); if (pid > 0) /*Process pid exist*/ { if (kill(pid, 0) == 0) { logs(LOG_CRIT, "file \"%s\" already exists.\n" "\t\tAnother program (pid: %d) seems to be running.\n", pid_path, pid); return RUNNING; } else /*Send signal to the old process get no reply.*/ { logs(LOG_DEBG, "Program (pid: %d) seems exit. Do some clean work now.\n", pid); remove(pid_path); return NOT_RUNNING; } } else if(0 == pid) { logs(LOG_INFO, "Last Running PID file is empty, clean it now.\n"); remove(pid_path); return NOT_RUNNING; } else /*Read pid from file "pid_path" failure*/ { logs(LOG_CRIT, "File \"%s\" already exists, but I can not read the process pid." "Maybe another program is running?\n" "If the program is not running, remove it and try again.\n" , pid_path); return RUNNING; } } return NOT_RUNNING; }
bool BufferedLoggerMark::flush() { if(_mst.size()>0){ if (crp()) _mst.cr(); logs(0, _mst.as_string()); _mst.reset(); return true; } return false; }
/** Logs a formatted message to a log file. * \param[in] iType - type of the log message (LT_*) * \param[in] bStd - log also to stdout/stderr if true * \param[in] pszStr - format string for the following parameters * \param[in] va - variable argument list */ void log_file::logv(int_t iType, bool bStd, const tchar_t* pszStr, va_list va) { if (iType < m_iLogLevel) return; tchar_t szBuf1[2048]; _vsntprintf(szBuf1, 2048, pszStr, va); // user passed stuff logs(iType, bStd, szBuf1); }
void Log::vlog(const char* tag, int opt, bool stp, bool crp, outputStream* st, const char* format, va_list ap) { // TODO: don't need to allocate buffer in some scenarios; see do_vsnprintf // in ostream.cpp; also, try to ensure buffer size is identical to size in // ostream.cpp char buf[2000]; size_t len; // optimized variable-argument buffer printing const char* message = outputStream::do_vsnprintf(buf, sizeof (buf), format, ap, crp, len); // log the message logs(tag, opt, stp, st, message); }
int record_runpid_file(const char *pid_path) { struct stat fStatBuf; int fd = -1; int mode = S_IROTH | S_IXOTH | S_IRGRP | S_IXGRP | S_IRWXU; char ipc_dir[64]={0}; strncpy(ipc_dir, pid_path, 64); dirname(ipc_dir); /*dirname() will modify ipc_dir and save the result*/ /* If folder "/tmp/pppsd doesnot exist, then we will create it"*/ if(stat(ipc_dir, &fStatBuf) < 0) { if(mkdir(ipc_dir, mode) < 0) { logs(LOG_CRIT, "cannot create %s: %s\n", ipc_dir, strerror(errno)); return -1; } (void)chmod(ipc_dir, mode); } logs(LOG_DEBG, "Create shared folder %s successfully.\n", ipc_dir); /*Create the process running PID file*/ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; if( (fd=open(pid_path, O_RDWR|O_CREAT|O_TRUNC, mode)) >= 0) { char pid[PID_ASCII_SIZE]; snprintf(pid, sizeof(pid), "%u\n", (unsigned) getpid()); write(fd, pid, strlen(pid)); close(fd); logs(LOG_DEBG, "Create PID file %s and write process pid[%u]\n", pid_path, getpid()); } else { logs(LOG_CRIT, "cannot create %s: %s\n", pid_path, strerror(errno)); return -1; } return 0; }
void signal_handler (int signo) { logs(LOG_INFO, "Receive signal %d\n", signo); if (SIGTERM==signo || SIGINT==signo) { g_ucStop = 0x01; } else if (SIGSEGV == signo) { _exit (1); } }
static void InitVfs(const CmdLineArgs& args) { TIMER(L"InitVfs"); const Paths paths(args); OsPath logs(paths.Logs()); CreateDirectories(logs, 0700); psSetLogDir(logs); // desired location for crashlog is now known. update AppHooks ASAP // (particularly before the following error-prone operations): AppHooks hooks = {0}; hooks.bundle_logs = psBundleLogs; hooks.get_log_dir = psLogDir; hooks.display_error = psDisplayError; app_hooks_update(&hooks); const size_t cacheSize = ChooseCacheSize(); g_VFS = CreateVfs(cacheSize); std::vector<CStr> mods = args.GetMultiple("mod"); mods.insert(mods.begin(), "public"); if (!args.Has("noUserMod")) mods.push_back("user"); OsPath modPath = paths.RData()/"mods"; OsPath modUserPath = paths.UserData()/"mods"; for (size_t i = 0; i < mods.size(); ++i) { size_t priority = i+1; // mods are higher priority than regular mountings, which default to priority 0 size_t flags = VFS_MOUNT_WATCH|VFS_MOUNT_ARCHIVABLE|VFS_MOUNT_MUST_EXIST; OsPath modName(mods[i]); g_VFS->Mount(L"", modPath / modName/"", flags, priority); g_VFS->Mount(L"", modUserPath / modName/"", flags, priority); } // We mount these dirs last as otherwise writing could result in files being placed in a mod's dir. g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/""); g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH); const OsPath readonlyConfig = paths.RData()/"config"/""; // Mounting with highest priority, so that a mod supplied user.cfg is harmless g_VFS->Mount(L"config/", readonlyConfig, 0, (size_t)-1); if(readonlyConfig != paths.Config()) g_VFS->Mount(L"config/", paths.Config(), 0, (size_t)-1); g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE); // (adding XMBs to archive speeds up subsequent reads) // note: don't bother with g_VFS->TextRepresentation - directories // haven't yet been populated and are empty. }
std::vector<TaskLog*>* Task::logs(bool includeChildren) const { std::vector<TaskLog*>* taskLogs = logs(); if (includeChildren && (childCount() > 0)) { std::vector<Task*> innerTasks = children(); for (std::vector<Task*>::iterator iter = innerTasks.begin(); iter != innerTasks.end(); iter++) { Task* child = *iter; std::vector<TaskLog*>* childLogs = child->logs(true); taskLogs->insert(taskLogs->end(), childLogs->begin(), childLogs->end()); delete childLogs; } } return taskLogs; }
bool Audio::init(){ logs().audio.write("[Audio] init"); if(!alutInit(NULL, 0)){ hardware.audio=false; return false; } ALenum error=alGetError(); if(error != AL_NO_ERROR){ logs().audio.write("[AudioObject] init error '"+String(alGetString(error))+"' "); console().write(String("audio init error '"+String(alGetString(error))+"' ")); return false; } alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); //NONE for none, AL_INVERSE_DISTANCE for other + //AL_INVERSE_DISTANCE_CLAMPED alDopplerFactor ( dopplerFactor ); error=alGetError(); active=true; //handle:play(); //handle:volume //default=1 (out of 1) //handle:range //default=0 (no range=play everywhere) //handle:directional //defaut=false //handle:loop //default=true //handle:id //handle id, internal error=alGetError(); if(error != AL_NO_ERROR){ return false; } return true; }
/** * Converts the temperature to readable output. */ void print_temp(const uint8_t subzero, uint8_t cel, uint8_t cel_frac_bits) { uint8_t buffer[sizeof(int)*8+1]; uint8_t i, j; logc((subzero)?'-':'+'); logi((int)cel); logs_P("."); itoa((cel_frac_bits*DS18X20_FRACCONV),buffer,10); j=4-strlen(buffer); for (i=0;i<j;i++) logs_P("0"); logs(buffer); logs_P(" Celsius"); }
void PrintDotFile::printDotFile(MethodDesc& mh, const char * suffix) { if (Log::isLogEnabled(LogStream::DOTDUMP)) { if (suffix != 0) { char* fname = Log::makeDotFileName(suffix); LogStream logs(fname); printDotFile(mh, logs.out()); delete [] fname; } else { printDotFile(mh, Log::log(LogStream::DOTDUMP).out()); } } }
int CGitLogList::CherryPickFrom(CString from, CString to) { CLogDataVector logs(&m_LogCache); if(logs.ParserFromLog(NULL,-1,0,&from,&to)) return -1; if(logs.size() == 0) return 0; CSysProgressDlg progress; if (progress.IsValid()) { progress.SetTitle(_T("Cherry Pick")); progress.SetAnimation(IDR_MOVEANI); progress.SetTime(true); progress.ShowModeless(this); } CBlockCacheForPath cacheBlock(g_Git.m_CurrentDir); for(int i=logs.size()-1;i>=0;i--) { if (progress.IsValid()) { progress.FormatPathLine(1, _T("Pick up %s"), logs.GetGitRevAt(i).m_CommitHash.ToString()); progress.FormatPathLine(2, _T("%s"), logs.GetGitRevAt(i).GetSubject()); progress.SetProgress(logs.size()-i, logs.size()); } if ((progress.IsValid())&&(progress.HasUserCancelled())) { //CMessageBox::Show(hwndExplorer, IDS_SVN_USERCANCELLED, IDS_APPNAME, MB_ICONINFORMATION); throw std::exception(CUnicodeUtils::GetUTF8(CString(_T("User canceled\r\n\r\n")))); return -1; } CString cmd,out; cmd.Format(_T("git.exe cherry-pick %s"),logs.GetGitRevAt(i).m_CommitHash.ToString()); out.Empty(); if(g_Git.Run(cmd,&out,CP_UTF8)) { throw std::exception(CUnicodeUtils::GetUTF8(CString(_T("Cherry Pick Failure\r\n\r\n"))+out)); return -1; } } return 0; }
static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { struct front_face *front = fh; struct poseidon *p = front->pd; logs(front); strcpy(cap->driver, "tele-video"); strcpy(cap->card, "Telegent Poseidon"); usb_make_path(p->udev, cap->bus_info, sizeof(cap->bus_info)); cap->version = KERNEL_VERSION(0, 0, 1); cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE; return 0; }
static void InitVfs(const CmdLineArgs& args, int flags) { TIMER(L"InitVfs"); const bool setup_error = (flags & INIT_HAVE_DISPLAY_ERROR) == 0; const Paths paths(args); OsPath logs(paths.Logs()); CreateDirectories(logs, 0700); psSetLogDir(logs); // desired location for crashlog is now known. update AppHooks ASAP // (particularly before the following error-prone operations): AppHooks hooks = {0}; hooks.bundle_logs = psBundleLogs; hooks.get_log_dir = psLogDir; if (setup_error) hooks.display_error = psDisplayError; app_hooks_update(&hooks); const size_t cacheSize = ChooseCacheSize(); g_VFS = CreateVfs(cacheSize); const OsPath readonlyConfig = paths.RData()/"config"/""; g_VFS->Mount(L"config/", readonlyConfig); // Engine localization files. g_VFS->Mount(L"l10n/", paths.RData()/"l10n"/""); MountMods(paths, GetMods(args, flags)); // We mount these dirs last as otherwise writing could result in files being placed in a mod's dir. g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/""); g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH); // Mounting with highest priority, so that a mod supplied user.cfg is harmless g_VFS->Mount(L"config/", readonlyConfig, 0, (size_t)-1); if(readonlyConfig != paths.Config()) g_VFS->Mount(L"config/", paths.Config(), 0, (size_t)-1); g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE); // (adding XMBs to archive speeds up subsequent reads) // note: don't bother with g_VFS->TextRepresentation - directories // haven't yet been populated and are empty. }
//-------------------------------------------------------------------------------- bool SDLog::openFile() //-------------------------------------------------------------------------------- { for ( int a = 1; a < 999; a++) { sprintf( fileName, "%d.txt", a ); if ( !SD.exists( fileName ) ) break; } dataFile = SD.open( fileName, FILE_WRITE ); if ( dataFile ) { logs( String("IEBUS HONDA V.") + String(IEBUS_VERSION) ); dataFile.close(); return true; } return false; }