config.render_minor_version = 0;
config.log_to_syslog = false;
config.log_to_console = true;
-
+ for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
+ for(int jj = 0; jj < 8; jj++) {
+ config.dev_log_to_syslog[ii][jj] = true;
+ config.dev_log_to_console[ii][jj] = true;
+ config.dev_log_recording[ii][jj] = true;
+ }
+ }
config.sound_fdd = 1;
config.sound_relay = 0;
config.sound_buttons = 0;
config.log_to_syslog = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
config.log_to_console = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
config.roma_kana_conversion = MyGetPrivateProfileInt(_T("Emulator"), _T("RomaKana"), config.roma_kana_conversion, config_path);
-
- for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
+
+ for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
uint32_t flags = 0;
- flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), 0x0000, config_path);
+ flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), 0xffff, config_path);
for(int jj = 0; jj < 8; jj++) {
config.dev_log_to_syslog[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
- csp_logger->set_device_node_log(ii, 1, jj, config.dev_log_to_syslog[ii][jj]);
flags >>= 1;
}
flags = 0;
flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), 0xffff, config_path);
for(int jj = 0; jj < 8; jj++) {
config.dev_log_to_console[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
- csp_logger->set_device_node_log(ii, 2, jj, config.dev_log_to_console[ii][jj]);
flags >>= 1;
}
flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), 0xffff, config_path);
for(int jj = 0; jj < 8; jj++) {
config.dev_log_recording[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
- csp_logger->set_device_node_log(ii, 0, jj, config.dev_log_recording[ii][jj]);
flags >>= 1;
}
}
#endif
#if defined(_USE_QT)
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
+ //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
#endif
}
MyWritePrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
MyWritePrivateProfileInt(_T("Emulator"), _T("RomaKana"), config.roma_kana_conversion, config_path);
- for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
+ for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
uint32_t flags = 0;
flags = 0;
for(int jj = 0; jj < 8; jj++) {
flags <<= 1;
if(config.dev_log_to_syslog[ii][jj]) flags |= 0x0001;
}
- flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
+ MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
flags = 0;
for(int jj = 0; jj < 8; jj++) {
flags <<= 1;
if(config.dev_log_to_console[ii][jj]) flags |= 0x0001;
}
- flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
+ MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
flags = 0;
for(int jj = 0; jj < 8; jj++) {
flags <<= 1;
if(config.dev_log_recording[ii][jj]) flags |= 0x0001;
}
- flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
+ MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
}
#endif
#if defined(_USE_QT) && !defined(Q_OS_WIN)
static void setup_logs(void)
{
- std::string archstr;
std::string delim;
- int bLogSYSLOG;
- int bLogSTDOUT;
char *p;
my_procname = "emu";
#else
cpp_confdir = cpp_homedir + ".config" + delim + my_procname + delim;
#endif
- bLogSYSLOG = (int)0;
- bLogSTDOUT = (int)1;
- //csp_logger = new CSP_Logger((bLogSYSLOG != 0), (bLogSTDOUT != 0), DEVICE_NAME); // Write to syslog, console
-
- archstr = "Generic";
-#if defined(__x86_64__)
- archstr = "amd64";
-#endif
-#if defined(__i386__)
- archstr = "ia32";
-#endif
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Start Common Source Project '%s'", my_procname.c_str());
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "(C) Toshiya Takeda / Qt Version K.Ohta");
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Architecture: %s", archstr.c_str());
-
- //csp_logger->debug_log(AGAR_LOG_INFO, " -? is print help(s).");
- csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Moduledir = %s home = %s", cpp_confdir.c_str(), cpp_homedir.c_str()); // Debug
#if !defined(Q_OS_CYGWIN)
{
QDir dir;
char homedir[PATH_MAX];
int thread_ret;
int w, h;
+ std::string archstr;
+ std::string emustr("emu");
+ std::string cfgstr(CONFIG_NAME);
setup_logs();
cpp_homedir.copy(homedir, PATH_MAX - 1, 0);
flag = FALSE;
+
+ load_config(create_local_path(_T("%s.ini"), _T(CONFIG_NAME)));
+
+ emustr = emustr + cfgstr;
+
+ csp_logger = new CSP_Logger(config.log_to_syslog, config.log_to_console, emustr.c_str()); // Write to syslog, console
+ csp_logger->set_log_stdout(CSP_LOG_DEBUG, true);
+ csp_logger->set_log_stdout(CSP_LOG_INFO, true);
+ csp_logger->set_log_stdout(CSP_LOG_WARN, true);
+
+ archstr = "Generic";
+#if defined(__x86_64__)
+ archstr = "amd64";
+#endif
+#if defined(__i386__)
+ archstr = "ia32";
+#endif
csp_logger->set_emu_vm_name(DEVICE_NAME); // Write to syslog, console
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Start Common Source Project '%s'", my_procname.c_str());
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "(C) Toshiya Takeda / Qt Version K.Ohta");
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Architecture: %s", archstr.c_str());
+
+ //csp_logger->debug_log(AGAR_LOG_INFO, " -? is print help(s).");
+ csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Moduledir = %s home = %s", cpp_confdir.c_str(), cpp_homedir.c_str()); // Debug
/*
* Into Qt's Loop.
*/
#endif
csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Audio and JOYSTICK subsystem was initialised.");
GuiMain = new QApplication(argc, argv);
- load_config(create_local_path(_T("%s.ini"), _T(CONFIG_NAME)));
-
+ //load_config(create_local_path(_T("%s.ini"), _T(CONFIG_NAME)));
+ for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
+ for(int jj = 0; jj < 8; jj++) {
+ csp_logger->set_device_node_log(ii, 1, jj, config.dev_log_to_syslog[ii][jj]);
+ csp_logger->set_device_node_log(ii, 2, jj, config.dev_log_to_console[ii][jj]);
+ csp_logger->set_device_node_log(ii, 0, jj, config.dev_log_recording[ii][jj]);
+ }
+ }
USING_FLAGS *using_flags = new USING_FLAGS(cfg);
// initialize emulation core
void do_send_string(void);
void do_set_string(QString);
void do_set_dev_log_to_console(bool f);
+ void do_set_dev_log_to_syslog(bool f);
void do_select_render_platform(void);
signals:
int quit_emu_thread(void);
int sig_send_string(QString);
int sig_set_dev_log_to_console(int, bool);
+ int sig_set_dev_log_to_syslog(int, bool);
int sig_select_render_platform(int);
} ActionControl;
QT_END_NAMESPACE
if(cons) {
flags = LOG_CONS;
}
- openlog(log_sysname.toLocal8Bit().constData(), flags | LOG_PID | LOG_NOWAIT, LOG_USER);
+ //openlog(devname, flags | LOG_PID | LOG_NOWAIT, LOG_USER);
+ openlog(devname, flags | LOG_PID , LOG_USER);
#endif
} else {
syslog_flag = false;
syslog_flag_out = syslog_flag;
cons_log_levels = 1 << CSP_LOG_INFO;
+
+ sys_log_levels = 1 << CSP_LOG_INFO;
+ sys_log_levels |= (1 << CSP_LOG_DEBUG);
+ sys_log_levels |= (1 << CSP_LOG_WARN);
linenum = 1;
line_wrap = 0;
this->debug_log(CSP_LOG_INFO, "Start logging.");
}
-
+
void CSP_Logger::debug_log(int level, const char *fmt, ...)
{
char strbuf[4096];
if(strbuf != NULL) {
nowtime = time(NULL);
gettimeofday(&tv, NULL);
- if(log_cons != 0) { // Print only
+ if((log_cons != 0) || (syslog_flag != 0)) {
timedat = localtime(&nowtime);
strftime(strbuf2, 255, "%Y-%m-%d %H:%M:%S", timedat);
snprintf(strbuf3, 23, ".%06ld", tv.tv_usec);
}
#if !defined(Q_OS_WIN)
if(sys_log_level_n != 0) {
- syslog(level_flag, "uS=%06ld %s",
- tv.tv_usec,
+ syslog(level_flag, "%s",
tmps->get_element_syslog().toLocal8Bit().constData());
}
#endif
QString get_element_syslog(void) {
QString s;
if(domain.isEmpty()) {
- s = mainstr;
+ s = timestamp + QString::fromUtf8(" ") + mainstr;
} else {
- s = domain + QString::fromUtf8(" ") + mainstr;
+ s = timestamp + QString::fromUtf8(" ") + domain + QString::fromUtf8(" ") + mainstr;
}
return s;
};
class Action_Control *action_SoundFilesFDD;
class Action_Control *action_SoundFilesRelay;
class Action_Control *action_SoundFilesButtons;
- QMenu *menuLogToConsole;
- QMenu *menuLogToSyslog;
+ //QMenu *menuLogToConsole;
+ //QMenu *menuLogToSyslog;
QMenu *menuDevLogToConsole;
QMenu *menuDevLogToSyslog;
QMenu *menu_SetRenderPlatform;
void do_set_syslog(bool);
void do_update_device_node_name(int id, const _TCHAR *name);
void do_set_dev_log_to_console(int id, bool f);
+ void do_set_dev_log_to_syslog(int id, bool f);
void do_set_roma_kana(bool f);
void do_set_render_mode_std(void);
void do_set_render_mode_tv(void);
emit sig_set_dev_log_to_console(num, f);
}
+void Action_Control::do_set_dev_log_to_syslog(bool f)
+{
+ int num = this->binds->getValue1();
+ emit sig_set_dev_log_to_syslog(num, f);
+}
+
void Ui_MainWindowBase::do_set_roma_kana(bool flag)
{
using_flags->get_config_ptr()->roma_kana_conversion = flag;
if(using_flags->get_vm_node_size() > id) {
action_DevLogToConsole[id]->setEnabled(true);
action_DevLogToConsole[id]->setVisible(true);
+
+ action_DevLogToSyslog[id]->setEnabled(true);
+ action_DevLogToSyslog[id]->setVisible(true);
} else {
action_DevLogToConsole[id]->setEnabled(false);
action_DevLogToConsole[id]->setVisible(false);
+
+ action_DevLogToSyslog[id]->setEnabled(false);
+ action_DevLogToSyslog[id]->setVisible(false);
}
char s[64] = {0};
snprintf(s, 60, "#%02d: %s", id, name);
action_DevLogToConsole[id]->setText(QString::fromUtf8(s));
+ action_DevLogToSyslog[id]->setText(QString::fromUtf8(s));
}
using_flags->get_config_ptr()->dev_log_to_console[num][0] = f;
}
+void Ui_MainWindowBase::do_set_dev_log_to_syslog(int num, bool f)
+{
+ csp_logger->set_device_node_log(num, 2, CSP_LOG_DEBUG, f);
+ using_flags->get_config_ptr()->dev_log_to_syslog[num][0] = f;
+}
+
void Ui_MainWindowBase::do_select_render_platform(int num)
{
int _major = 0;
}
}
menuDevLogToConsole->setTitle(QApplication::translate("MainWindow", "Per Device", 0));
+ menuDevLogToSyslog->setTitle(QApplication::translate("MainWindow", "Per Device", 0));
menu_SetRenderPlatform->setTitle(QApplication::translate("MainWindow", "Video Platform(need restart)", 0));
action_SetRenderPlatform[RENDER_PLATFORMS_OPENGL3_MAIN]->setText(QApplication::translate("MainWindow", "OpenGLv3.0", 0));
menuEmulator->addAction(menuDevLogToConsole->menuAction());
menuEmulator->addSeparator();
menuEmulator->addAction(action_LogToSyslog);
+ menuEmulator->addAction(menuDevLogToSyslog->menuAction());
menuEmulator->addSeparator();
menuEmulator->addAction(action_LogView);
menuEmulator->addSeparator();
action_LogToSyslog->setCheckable(true);
action_LogToSyslog->setEnabled(true);
if(using_flags->get_config_ptr()->log_to_syslog != 0) action_LogToSyslog->setChecked(true);
+ menuDevLogToSyslog = new QMenu(this);
+ menuDevLogToSyslog->setToolTipsVisible(true);
+ for(int i = 0; i < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); i++) {
+ action_DevLogToSyslog[i] = new Action_Control(this, using_flags);
+ action_DevLogToSyslog[i]->setCheckable(true);
+ action_DevLogToSyslog[i]->setEnabled(false);
+ action_DevLogToSyslog[i]->binds->setValue1(i);
+ menuDevLogToSyslog->addAction(action_DevLogToSyslog[i]);
+ if(using_flags->get_config_ptr()->dev_log_to_syslog[i][0]) action_DevLogToSyslog[i]->setChecked(true);
+ connect(action_DevLogToSyslog[i], SIGNAL(toggled(bool)),
+ action_DevLogToSyslog[i], SLOT(do_set_dev_log_to_syslog(bool)));
+ connect(action_DevLogToSyslog[i], SIGNAL(sig_set_dev_log_to_syslog(int, bool)),
+ this, SLOT(do_set_dev_log_to_syslog(int, bool)));
+ }
action_LogToConsole = new Action_Control(this, using_flags);
action_LogToConsole->setCheckable(true);
/*
* アプリケーション初期化
*/
-
- csp_logger = new CSP_Logger(false, true, NULL); // Write to syslog, console
- csp_logger->set_log_stdout(CSP_LOG_DEBUG, true);
- csp_logger->set_log_stdout(CSP_LOG_INFO, true);
- csp_logger->set_log_stdout(CSP_LOG_WARN, true);
Q_INIT_RESOURCE(commontexts);
Q_INIT_RESOURCE(shaders);
nErrorCode = MainLoop(argc, argv, &config);