1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 09:30:39 +02:00

Replaced every message output by calls to the log macros.

This commit is contained in:
Ayla 2010-09-17 22:31:09 +02:00
parent 7d0c0e958c
commit 7c9364780b
13 changed files with 85 additions and 85 deletions

View File

@ -1,11 +1,14 @@
#include "cpu.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include "cpu.h"
#include "debug.h"
#define SYSFS_CPUFREQ_DIR "/sys/devices/system/cpu/cpu0/cpufreq"
#define SYSFS_CPUFREQ_MAX SYSFS_CPUFREQ_DIR "/scaling_max_freq"
#define SYSFS_CPUFREQ_SET SYSFS_CPUFREQ_DIR "/scaling_setspeed"
@ -14,11 +17,11 @@ void writeStringToFile(const char *path, const char *content)
{
int fd = open(path, O_RDWR);
if (fd == -1) {
fprintf(stderr, "Failed to open \"%s\": %s\n", path, strerror(errno));
WARNING("Failed to open '%s': %s\n", path, strerror(errno));
} else {
ssize_t written = write(fd, content, strlen(content));
if (written == -1) {
fprintf(stderr, "Error writing \"%s\": %s\n", path, strerror(errno));
WARNING("Error writing '%s': %s\n", path, strerror(errno));
}
close(fd);
}

View File

@ -29,6 +29,7 @@
#include "filelister.h"
#include "utilities.h"
#include "debug.h"
using namespace std;
@ -72,7 +73,7 @@ void FileLister::browse()
if (showDirectories || showFiles) {
DIR *dirp;
if ((dirp = opendir(path.c_str())) == NULL) {
cout << "Error: opendir(" << path << ")" << endl;
ERROR("Error: opendir(%s)\n", path.c_str());
return;
}
@ -92,7 +93,7 @@ void FileLister::browse()
filepath = path + file;
int statRet = stat(filepath.c_str(), &st);
if (statRet == -1) {
cout << "\033[0;34mGMENU2X:\033[0;31m stat failed on '" << filepath << "' with error '" << strerror(errno) << "'\033[0m" << endl;
ERROR("Stat failed on '%s' with error '%s'\n", filepath.c_str(), strerror(errno));
continue;
}
if (find(excludes.begin(), excludes.end(), file) != excludes.end())

View File

@ -69,6 +69,8 @@
#include "menusettingimage.h"
#include "menusettingdir.h"
#include "debug.h"
#include <sys/mman.h>
#ifdef TARGET_PANDORA
@ -112,17 +114,15 @@ static const char *colorToString(enum color c)
return colorNames[c];
}
int main(int /*argc*/, char */*argv*/[]) {
cout << "----" << endl;
cout << "GMenu2X starting: If you read this message in the logs, check http://gmenu2x.sourceforge.net/page/Troubleshooting for a solution" << endl;
cout << "----" << endl;
int main(int /*argc*/, char * /*argv*/[]) {
INFO("----\nGMenu2X starting: If you read this message in the logs, check http://gmenu2x.sourceforge.net/page/Troubleshooting for a solution\n----\n");
signal(SIGINT,&exit);
GMenu2X app;
#ifdef DEBUG
cout << "Starting main()" << endl;
#endif
DEBUG("Starting main()\n");
app.main();
return 0;
}
@ -264,7 +264,7 @@ GMenu2X::GMenu2X() {
//Screen
if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK)<0 ) {
cout << "\033[0;34mGMENU2X:\033[0;31m Could not initialize SDL:\033[0m " << SDL_GetError() << endl;
ERROR("Could not initialize SDL: %s\n", SDL_GetError());
quit();
}
@ -288,9 +288,8 @@ GMenu2X::GMenu2X() {
initMenu();
if (!fileExists(confStr["wallpaper"])) {
#ifdef DEBUG
cout << "Searching wallpaper" << endl;
#endif
DEBUG("Searching wallpaper\n");
FileLister fl("skins/"+confStr["skin"]+"/wallpapers",false,true);
fl.setFilter(".png,.jpg,.jpeg,.bmp");
fl.browse();
@ -403,7 +402,7 @@ void GMenu2X::initFont() {
string fontFile = sc.getSkinFilePath("imgs/font.png");
if (fontFile.empty()) {
cout << "Font png not found!" << endl;
ERROR("Font png not found!\n");
quit();
exit(-1);
}
@ -795,7 +794,7 @@ void GMenu2X::main() {
uint sectionsCoordX = 24;
SDL_Rect re = {0,0,0,0};
bool helpDisplayed = false;
#ifdef DEBUG
#ifdef WITH_DEBUG
//framerate
long tickFPS = SDL_GetTicks();
int drawn_frames = 0;
@ -913,7 +912,7 @@ void GMenu2X::main() {
}
#ifdef DEBUG
#ifdef WITH_DEBUG
//framerate
drawn_frames++;
if (tickNow-tickFPS>=1000) {
@ -1031,7 +1030,7 @@ void GMenu2X::explorer() {
//if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
//try relaunching gmenu2x
fprintf(stderr, "Error executing selected application, re-launching gmenu2x\n");
ERROR("Error executing selected application, re-launching gmenu2x\n");
chdir(getExePath().c_str());
execlp("./gmenu2x", "./gmenu2x", NULL);
}
@ -1167,7 +1166,7 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
string line;
while (getline(skinconf, line, '\n')) {
line = trim(line);
cout << "skinconf: " << line << endl;
DEBUG("skinconf: '%s'\n", line.c_str());
string::size_type pos = line.find("=");
string name = trim(line.substr(0,pos));
string value = trim(line.substr(pos+1,line.length()));
@ -1460,9 +1459,8 @@ void GMenu2X::editLink() {
//G
menu->selLinkApp()->setBacklight(linkBacklight);
#ifdef DEBUG
cout << "New Section: " << newSection << endl;
#endif
INFO("New Section: '%s'\n", newSection.c_str());
//if section changed move file and update link->file
if (oldSection!=newSection) {
vector<string>::const_iterator newSectionIndex = find(menu->getSections().begin(),menu->getSections().end(),newSection);
@ -1477,9 +1475,9 @@ void GMenu2X::editLink() {
}
rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str());
menu->selLinkApp()->renameFile(newFileName);
#ifdef DEBUG
cout << "New section index: " << newSectionIndex - menu->getSections().begin() << endl;
#endif
INFO("New section index: %i.\n", newSectionIndex - menu->getSections().begin());
menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->getSections().begin());
}
menu->selLinkApp()->save();
@ -1816,7 +1814,7 @@ int GMenu2X::getVolume() {
if(mixer)
{
if (ioctl(mixer, SOUND_MIXER_READ_VOLUME, &basevolume) == -1) {
fprintf(stderr, "Failed opening mixer for read - VOLUME\n");
ERROR("Failed opening mixer for read - VOLUME\n");
}
close(mixer);
if(basevolume != -1)
@ -1833,7 +1831,7 @@ void GMenu2X::setVolume(int vol) {
if(mixer)
{
if (ioctl(mixer, SOUND_MIXER_WRITE_VOLUME, &oss_volume) == -1) {
fprintf(stderr, "Failed opening mixer for write - VOLUME\n");
ERROR("Failed opening mixer for write - VOLUME\n");
}
close(mixer);
}
@ -1887,7 +1885,7 @@ string GMenu2X::getDiskFree() {
((unsigned long long)b.f_blocks * b.f_frsize) / 1048576;
ss << free << "/" << total << "MB";
ss >> df;
} else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl;
} else WARNING("statvfs failed with error '%s'.\n", strerror(errno));
return df;
}

View File

@ -21,8 +21,10 @@
#include <iostream>
#include <sstream>
#include <fstream>
#include "inputmanager.h"
#include "utilities.h"
#include "debug.h"
using namespace std;
@ -41,14 +43,13 @@ void InputManager::init(const string &conffile) {
for (int x=0; x<numJoy; x++) {
SDL_Joystick *joy = SDL_JoystickOpen(x);
if (joy) {
#ifdef DEBUG
cout << "Initialized joystick: " << SDL_JoystickName(x) << endl;
#endif
INFO("Initialized joystick: '%s'\n", SDL_JoystickName(x));
joysticks.push_back(joy);
}
#ifdef DEBUG
else cout << "Failed to initialize joystick: " << x << endl;
#endif
else WARNING("Failed to initialize joystick: %i\n", x);
}
setActionsCount(14);

View File

@ -23,10 +23,12 @@
#include <fstream>
#include <sstream>
#include "linkapp.h"
#include "menu.h"
#include "selector.h"
#include "textmanualdialog.h"
#include "debug.h"
using namespace std;
@ -100,7 +102,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, InputManager &inputMgr_,
} else if (name == "selectoraliases") {
setAliasFile( value );
} else {
cout << "Unrecognized option: " << name << endl;
WARNING("Unrecognized option: '%s'\n", name.c_str());
break;
}
}
@ -252,7 +254,7 @@ bool LinkApp::save() {
sync();
return true;
} else
cout << "\033[0;34mGMENU2X:\033[0;31m Error while opening the file '" << file << "' for write\033[0m" << endl;
ERROR("Error while opening the file '%s' for write.\n", file.c_str());
return false;
}
@ -436,9 +438,7 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
if (volume()>=0)
gmenu2x->setVolume(volume());
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Executing '" << title << "' (" << exec << " " << params << ")" << endl;
#endif
INFO("Executing '%s' (%s %s)\n", title.c_str(), exec.c_str(), params.c_str());
//check if we have to quit
string command = cmdclean(exec);

View File

@ -31,6 +31,7 @@
#include "menu.h"
#include "filelister.h"
#include "utilities.h"
#include "debug.h"
using namespace std;
@ -207,9 +208,8 @@ bool Menu::addLink(string path, string file, string section) {
linkpath = "sections/"+section+"/"+title+linkpath;
x++;
}
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Adding link: " << linkpath << endl;
#endif
INFO("Adding link: '%s'\n", linkpath.c_str());
if (path[path.length()-1]!='/') path += "/";
//search for a manual
@ -241,9 +241,8 @@ bool Menu::addLink(string path, string file, string section) {
}
}
}
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Manual: " << manual << endl;
#endif
INFO("Manual: '%s'\n", manual.c_str());
string shorttitle=title, description="", exec=path+file, icon="";
@ -266,17 +265,17 @@ bool Menu::addLink(string path, string file, string section) {
sync();
int isection = find(sections.begin(),sections.end(),section) - sections.begin();
if (isection>=0 && isection<(int)sections.size()) {
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Section: " << sections[isection] << "(" << isection << ")" << endl;
#endif
INFO("Section: '%s(%i)'\n", sections[isection].c_str(), isection);
LinkApp* link = new LinkApp(gmenu2x, gmenu2x->input, linkpath.c_str());
link->setSize(gmenu2x->skinConfInt["linkWidth"],gmenu2x->skinConfInt["linkHeight"]);
links[isection].push_back( link );
}
} else {
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0;31m Error while opening the file '" << linkpath << "' for write\033[0m" << endl;
#endif
ERROR("Error while opening the file '%s' for write.\n", linkpath.c_str());
return false;
}
@ -295,9 +294,8 @@ bool Menu::addSection(const string &sectionName) {
}
void Menu::deleteSelectedLink() {
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Deleting link " << selLink()->getTitle() << endl;
#endif
INFO("Deleting link '%s'\n", selLink()->getTitle().c_str());
if (selLinkApp()!=NULL)
unlink(selLinkApp()->getFile().c_str());
gmenu2x->sc.del(selLink()->getIconPath());
@ -306,9 +304,8 @@ void Menu::deleteSelectedLink() {
}
void Menu::deleteSelectedSection() {
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Deleting section " << selSection() << endl;
#endif
INFO("Deleting section '%s'\n", selSection().c_str());
gmenu2x->sc.del("sections/"+selSection()+".png");
links.erase( links.begin()+selSectionIndex() );
sections.erase( sections.begin()+selSectionIndex() );

View File

@ -32,6 +32,7 @@
#include "selector.h"
#include "filelister.h"
#include "gmenu2x.h"
#include "debug.h"
using namespace std;
@ -157,7 +158,7 @@ int Selector::exec(int startSelection) {
result = false;
} else {
dir = dir.substr(0,p+1);
cout << dir << endl;
INFO("%s\n", dir.c_str());
selected = 0;
firstElement = 0;
prepare(&fl,&screens,&titles);
@ -204,9 +205,9 @@ void Selector::prepare(FileLister *fl, vector<string> *screens, vector<string> *
titles->at(i) = getAlias(noext);
if (titles->at(i)=="")
titles->at(i) = noext;
#ifdef DEBUG
cout << "\033[0;34mGMENU2X:\033[0m Searching for screen " << screendir << noext << ".png" << endl;
#endif
DEBUG("Searching for screen '%s%s.png'\n", screendir.c_str(), noext.c_str());
if (fileExists(screendir+noext+".png"))
screens->at(i) = screendir+noext+".png";
else if (fileExists(screendir+noext+".jpg"))

View File

@ -76,11 +76,11 @@ void SFontPlus::initFont(SDL_Surface *font, const string &characters) {
if (font==NULL) return;
surface = font;
Uint32 pink = SDL_MapRGB(surface->format, 255,0,255);
#ifdef _DEBUG
#ifdef DEBUG
bool utf8 = false;
for (uint x=0; x<characters.length(); x++) {
if (!utf8) utf8 = (unsigned char)characters[x]>128;
if (utf8) printf("%d\n", (unsigned char)characters[x]);
if (utf8) DEBUG("%d\n", (unsigned char)characters[x]);
}
#endif

View File

@ -25,6 +25,7 @@ using namespace std;
#include "surface.h"
#include "utilities.h"
#include "debug.h"
RGBAColor strtorgba(const string &strColor) {
RGBAColor c = {0,0,0,255};
@ -131,14 +132,14 @@ void Surface::load(const string &img, bool alpha, const string &skin) {
raw = SDL_DisplayFormat(buf);
SDL_FreeSurface(buf);
} else {
cout << "Couldn't load surface " << img << endl;
ERROR("Couldn't load surface '%s'\n", img.c_str());
}
}
void Surface::lock() {
if ( SDL_MUSTLOCK(raw) && !locked ) {
if ( SDL_LockSurface(raw) < 0 ) {
fprintf(stderr, "Can't lock surface: %s\n", SDL_GetError());
ERROR("Can't lock surface: '%s'\n", SDL_GetError());
SDL_Quit();
}
locked = true;

View File

@ -21,8 +21,8 @@
#include "surfacecollection.h"
#include "surface.h"
#include "utilities.h"
#include "debug.h"
using std::cout;
using std::endl;
using std::string;
@ -52,7 +52,7 @@ string SurfaceCollection::getSkinFilePath(const string &file) {
void SurfaceCollection::debug() {
SurfaceHash::iterator end = surfaces.end();
for(SurfaceHash::iterator curr = surfaces.begin(); curr != end; curr++){
cout << "key: " << curr->first << endl;
DEBUG("key: %i\n", curr->first);
}
}
@ -67,9 +67,8 @@ Surface *SurfaceCollection::add(Surface *s, const string &path) {
}
Surface *SurfaceCollection::add(const string &path, bool alpha) {
#ifdef DEBUG
cout << "Adding surface: " << path << endl;
#endif
DEBUG("Adding surface: '%s'\n", path.c_str());
if (exists(path)) del(path);
string filePath = path;
@ -85,9 +84,7 @@ Surface *SurfaceCollection::add(const string &path, bool alpha) {
}
Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
#ifdef DEBUG
cout << "Adding skin surface: " << path << endl;
#endif
DEBUG("Adding skin surface: '%s'\n", path.c_str());
if (path.empty()) return NULL;
if (exists(path)) del(path);

View File

@ -24,6 +24,7 @@
#include <stdarg.h>
#include "translator.h"
#include "debug.h"
using namespace std;
@ -66,9 +67,8 @@ string Translator::translate(const string &term,const char *replacestr,...) {
if (i != translations.end()) {
result = i->second;
}
#ifdef DEBUG
else cout << "Untranslated string: " << term << endl;
#endif
else WARNING("Untranslated string: '%s'\n", term.c_str());
}
va_list arglist;

View File

@ -29,6 +29,7 @@
#include <SDL.h>
#include "utilities.h"
#include "debug.h"
using namespace std;
@ -73,9 +74,7 @@ bool rmtree(string path) {
struct dirent *dptr;
string filepath;
#ifdef DEBUG
cout << "RMTREE: " << path << endl;
#endif
DEBUG("RMTREE: '%s'\n", path.c_str());
if ((dirp = opendir(path.c_str())) == NULL) return false;
if (path[path.length()-1]!='/') path += "/";

View File

@ -18,8 +18,11 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <iostream>
#include "wallpaperdialog.h"
#include "filelister.h"
#include "debug.h"
using namespace std;
@ -44,9 +47,8 @@ bool WallpaperDialog::exec()
for (uint i=0; i<fl.getFiles().size(); i++)
wallpapers.push_back(fl.getFiles()[i]);
}
#ifdef DEBUG
cout << "Wallpapers: " << wallpapers.size() << endl;
#endif
DEBUG("Wallpapers: %i\n", wallpapers.size());
uint i, selected = 0, firstElement = 0, iY;
while (!close) {