Commit 8232b1e3 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Renamed co_debug to co_log, added optional logging to file and multiple logging levels.

parent 2e643250
...@@ -55,7 +55,7 @@ int main(int argc, char* argv[]) ...@@ -55,7 +55,7 @@ int main(int argc, char* argv[])
int sts; int sts;
char dev_name[20] = "eth1"; char dev_name[20] = "eth1";
setDebug(1); log_setLevel(LOG_TRACE);
QApplication app(argc, argv); QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle()); QApplication::setStyle(new PwrStyle());
......
...@@ -228,15 +228,14 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr, ...@@ -228,15 +228,14 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData(); GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile); sts = data->read(datafile);
if (EVEN(sts)) if (EVEN(sts)) {
{ delete data;
return sts; return sts;
} }
sts = data->get_value(Attr, Buf, BufSize); sts = data->get_value(Attr, Buf, BufSize);
delete data; delete data;
return sts; return sts;
} }
...@@ -251,19 +250,17 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr, ...@@ -251,19 +250,17 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData(); GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile); sts = data->read(datafile);
if (EVEN(sts)) if (EVEN(sts)) {
{ delete data;
return sts; return sts;
} }
sts = data->modify_value(Attr, Value); sts = data->modify_value(Attr, Value);
if (ODD(sts)) if (ODD(sts)) {
{
data->print(datafile); data->print(datafile);
} }
delete data; delete data;
return sts; return sts;
} }
......
...@@ -58,7 +58,7 @@ int main(int argc, char* argv[]) ...@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
unsigned int itemcnt; unsigned int itemcnt;
char servername[40] = ""; char servername[40] = "";
setDebug(1); log_setLevel(LOG_TRACE);
// Get options // Get options
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "co_cdh.h" #include "co_cdh.h"
#include "co_dcli.h" #include "co_dcli.h"
#include "co_dcli_msg.h" #include "co_dcli_msg.h"
#include "co_debug.h" #include "co_log.h"
#include "co_string.h" #include "co_string.h"
typedef enum { typedef enum {
...@@ -175,7 +175,7 @@ int dcli_replace_env(const char* str, char* newstr) ...@@ -175,7 +175,7 @@ int dcli_replace_env(const char* str, char* newstr)
if ((value = getenv(lower_symbol)) == NULL) { if ((value = getenv(lower_symbol)) == NULL) {
/* It was no symbol */ /* It was no symbol */
if (str_StartsWith(str, "$pwr")) { if (str_StartsWith(str, "$pwr")) {
debug_print("Warning! Could not resolve environment variable $%s\n", lower_symbol); log_debug("Warning! Could not resolve environment variable $%s\n", lower_symbol);
} }
*t = *s; *t = *s;
t++; t++;
...@@ -207,7 +207,7 @@ int dcli_replace_env(const char* str, char* newstr) ...@@ -207,7 +207,7 @@ int dcli_replace_env(const char* str, char* newstr)
if ((value = getenv(lower_symbol)) == NULL) { if ((value = getenv(lower_symbol)) == NULL) {
/* It was no symbol */ /* It was no symbol */
if (str_StartsWith(str, "$pwr")) { if (str_StartsWith(str, "$pwr")) {
debug_print("Warning! Could not resolve environment variable $%s\n", lower_symbol); log_debug("Warning! Could not resolve environment variable $%s\n", lower_symbol);
} }
*t = 0; *t = 0;
} else { } else {
......
...@@ -34,47 +34,84 @@ ...@@ -34,47 +34,84 @@
* General Public License plus this exception. * General Public License plus this exception.
*/ */
#include "co_debug.h" #include "co_log.h"
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
static int DEBUG = 0; static int LEVEL = 0;
static FILE* FP = NULL;
static int QUIET = 0;
void setDebug(int debug) void log_setLevel(int level)
{ {
DEBUG = debug; LEVEL = level;
} }
void log_setFile(FILE* fp)
{
FP = fp;
}
void log_setQuiet(int quiet)
{
QUIET = quiet;
}
static const char *level_names[] = {
"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"
};
static const char *level_colors[] = {
"\x1b[94m", "\x1b[36m", "\x1b[32m", "\x1b[33m", "\x1b[31m", "\x1b[35m"
};
void print_time(FILE* stream, int fulldate) void print_time(FILE* stream, int fulldate)
{ {
time_t t;
struct tm* tm;
char Date[11], Time[11]; char Date[11], Time[11];
time(&t); time_t t = time(NULL);
tm = localtime(&t); struct tm* lt = localtime(&t);
if (fulldate) { if (fulldate) {
strftime(Date, 11, "%Y-%m-%d", tm); strftime(Date, 11, "%Y-%m-%d", lt);
fprintf(stream, "%s ", Date); fprintf(stream, "%s ", Date);
} }
strftime(Time, 11, "%H:%M:%S", tm); strftime(Time, 11, "%H:%M:%S", lt);
fprintf(stream, "%s", Time); fprintf(stream, "%s", Time);
} }
void dbg_print(const char* file, int line, const char* fmt, ...) void log_print(int level, const char* file, int line, const char* fmt, ...)
{ {
if (DEBUG) { if (level < LEVEL) {
return;
}
if (!QUIET) {
// 1. print timestamp // 1. print timestamp
print_time(stderr); print_time(stderr);
// 2. print filename only, without path // 2. print filename only, without path
const char* file2 = strrchr(file, '/'); const char* file2 = strrchr(file, '/');
file2 = file2 ? (file2 + 1) : file; file2 = file2 ? (file2 + 1) : file;
fprintf(stderr, " %s:%d: ", file2, line); fprintf(stderr, " %s%-5s\x1b[0m %s:%d: ",
level_colors[level], level_names[level], file2, line);
// 3. print the actual debug message // 3. print the actual debug message
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
va_end(args); va_end(args);
} }
if (FP) {
// 1. print timestamp
print_time(FP);
// 2. print filename only, without path
const char* file2 = strrchr(file, '/');
file2 = file2 ? (file2 + 1) : file;
fprintf(FP, " %-5s %s:%d: ", level_names[level], file2, line);
// 3. print the actual debug message
va_list args;
va_start(args, fmt);
vfprintf(FP, fmt, args);
va_end(args);
}
} }
\ No newline at end of file
...@@ -36,16 +36,26 @@ ...@@ -36,16 +36,26 @@
// TODO: The functionality of this file overlaps that of rt_errh. // TODO: The functionality of this file overlaps that of rt_errh.
#ifndef CO_DEBUG #ifndef CO_LOG_H
#define CO_DEBUG #define CO_LOG_H
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
void setDebug(int debug); enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
void log_setLevel(int level);
void log_setQuiet(int quiet);
void log_setFile(FILE* fp);
void print_time(FILE* stream, int fulldate = 0); void print_time(FILE* stream, int fulldate = 0);
void dbg_print(const char* file, int line, const char* fmt, ...); void log_print(int level, const char* file, int line, const char* fmt, ...);
#define debug_print(fmt, args...) dbg_print(__FILE__, __LINE__, fmt, ##args); #define log_trace(...) log_print(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__);
#define log_debug(...) log_print(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__);
#define log_info(...) log_print(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__);
#define log_warn(...) log_print(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__);
#define log_error(...) log_print(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__);
#define log_fatal(...) log_print(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__);
#endif #endif
\ No newline at end of file
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#ifndef CO_UNIQUE_PTR #ifndef CO_UNIQUE_PTR
#define CO_UNIQUE_PTR #define CO_UNIQUE_PTR
#include "co_debug.h"
// std::unique_ptr for single objects -> free memory with 'delete' // std::unique_ptr for single objects -> free memory with 'delete'
template<typename T> template<typename T>
class unique_ptr { class unique_ptr {
......
...@@ -200,7 +200,7 @@ mkdir := mkdir ...@@ -200,7 +200,7 @@ mkdir := mkdir
# Set to /buildversion for frozen dbs versions # Set to /buildversion for frozen dbs versions
wblflags := wblflags :=
warnings := -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-sign-compare -Wno-missing-field-initializers -Wno-deprecated -Wno-cast-function-type warnings := -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-sign-compare -Wno-missing-field-initializers -Wno-deprecated -Wno-cast-function-type -Wno-deprecated
ifeq ($(pwre_btype),rls) ifeq ($(pwre_btype),rls)
cflags := $(cross_compile) -c -O3 -D_GNU_SOURCE -DPWR_NDEBUG -D_REENTRANT -fPIC $(warnings) cflags := $(cross_compile) -c -O3 -D_GNU_SOURCE -DPWR_NDEBUG -D_REENTRANT -fPIC $(warnings)
......
...@@ -78,7 +78,7 @@ WVsel* WbQt::vsel_new(pwr_tStatus* status, const char* name, ...@@ -78,7 +78,7 @@ WVsel* WbQt::vsel_new(pwr_tStatus* status, const char* name,
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
if (argc >= 2 && streq(argv[1], "-m")) { if (argc >= 2 && streq(argv[1], "-m")) {
wb_erep::printMethods(); wb_erep::printMethods();
exit(0); exit(0);
...@@ -126,7 +126,7 @@ WbQt::WbQt(int argc, char* argv[]) ...@@ -126,7 +126,7 @@ WbQt::WbQt(int argc, char* argv[])
strcpy(volumename, "directory"); strcpy(volumename, "directory");
sw_projectvolume = 1; sw_projectvolume = 1;
arg_cnt = 0; arg_cnt = 0;
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "co_debug.h" #include "co_log.h"
#include "cow_style_qt.h" #include "cow_style_qt.h"
...@@ -79,7 +79,7 @@ CmdQt::CmdQt(int argc, char* argv[]) ...@@ -79,7 +79,7 @@ CmdQt::CmdQt(int argc, char* argv[])
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
QApplication app(argc, argv); QApplication app(argc, argv);
QApplication::setStyle(new PwrStyle()); QApplication::setStyle(new PwrStyle());
new CmdQt(argc, argv); new CmdQt(argc, argv);
......
...@@ -436,16 +436,16 @@ WAttText* WNavQt::watttext_new( ...@@ -436,16 +436,16 @@ WAttText* WNavQt::watttext_new(
void WNavQt::wge_subwindow_loop(WGe* wge) void WNavQt::wge_subwindow_loop(WGe* wge)
{ {
debug_print(" before wge_subwindow_loop\n"); log_debug(" before wge_subwindow_loop\n");
QApplication::exec(); QApplication::exec();
debug_print(" after wge_subwindow_loop\n"); log_debug(" after wge_subwindow_loop\n");
} }
void WNavQt::wge_modal_loop(WGe* wge) void WNavQt::wge_modal_loop(WGe* wge)
{ {
debug_print(" before wge_modal_loop\n"); log_debug(" before wge_modal_loop\n");
QApplication::exec(); QApplication::exec();
debug_print(" after wge_modal_loop\n"); log_debug(" after wge_modal_loop\n");
} }
void WNavQt::message_dialog(char* title, char* text) void WNavQt::message_dialog(char* title, char* text)
......
...@@ -56,7 +56,7 @@ void close_cb(void* ctx, void* xhelp) ...@@ -56,7 +56,7 @@ void close_cb(void* ctx, void* xhelp)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
int sts; int sts;
QApplication app(argc, argv); QApplication app(argc, argv);
...@@ -80,7 +80,7 @@ CoHelpQt::CoHelpQt(int argc, char* argv[], int* return_sts) ...@@ -80,7 +80,7 @@ CoHelpQt::CoHelpQt(int argc, char* argv[], int* return_sts)
{ {
pwr_tStatus sts; pwr_tStatus sts;
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
} }
......
...@@ -71,11 +71,11 @@ static void rtmon_close_cb(void* ctx) ...@@ -71,11 +71,11 @@ static void rtmon_close_cb(void* ctx)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
int sts; int sts;
char display[80] = ""; char display[80] = "";
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
if (streq(argv[i], "-h")) { if (streq(argv[i], "-h")) {
......
...@@ -71,13 +71,13 @@ static void statusmon_close(void* ctx) ...@@ -71,13 +71,13 @@ static void statusmon_close(void* ctx)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
int sts; int sts;
int mode = nodelist_eMode_SystemStatus; int mode = nodelist_eMode_SystemStatus;
int view_descr = 0; int view_descr = 0;
char language[20] = ""; char language[20] = "";
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
if (streq(argv[i], "-h")) { if (streq(argv[i], "-h")) {
......
...@@ -551,7 +551,7 @@ void XttQtWidget::valchanged_cmd_entry() ...@@ -551,7 +551,7 @@ void XttQtWidget::valchanged_cmd_entry()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
int sts; int sts;
QApplication app(argc, argv); QApplication app(argc, argv);
...@@ -598,7 +598,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts) ...@@ -598,7 +598,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts)
strcat(title, nodename); strcat(title, nodename);
} }
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
} }
......
...@@ -73,7 +73,7 @@ static int timeout_func() ...@@ -73,7 +73,7 @@ static int timeout_func()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
pwr_tStatus sts; pwr_tStatus sts;
int i; int i;
char str[256]; char str[256];
...@@ -85,7 +85,7 @@ int main(int argc, char* argv[]) ...@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
/* If arguments, treat them as a command and then exit */ /* If arguments, treat them as a command and then exit */
// Open directory volume as default // Open directory volume as default
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
str[0] = 0; str[0] = 0;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
......
...@@ -64,7 +64,7 @@ static void usage() ...@@ -64,7 +64,7 @@ static void usage()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
setDebug(1); log_setLevel(LOG_TRACE);
int i; int i;
pwr_tFileName file; pwr_tFileName file;
char graph_name[80]; char graph_name[80];
...@@ -88,7 +88,7 @@ int main(int argc, char* argv[]) ...@@ -88,7 +88,7 @@ int main(int argc, char* argv[])
CoXHelpQt* xhelp = new CoXHelpQt(0, xhelp_eUtility_Wtt, &sts); CoXHelpQt* xhelp = new CoXHelpQt(0, xhelp_eUtility_Wtt, &sts);
CoXHelpQt::set_default(xhelp); CoXHelpQt::set_default(xhelp);
debug_print("%s ", argv[0]); log_debug("%s ", argv[0]);
if (argc > 1) { if (argc > 1) {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]); fprintf(stderr, "%s ", argv[i]);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#ifndef QT_HELPERS_H #ifndef QT_HELPERS_H
#define QT_HELPERS_H #define QT_HELPERS_H
#include "co_debug.h" #include "co_log.h"
#include <QAction> #include <QAction>
#include <QComboBox> #include <QComboBox>
......
...@@ -434,7 +434,7 @@ void CoWowQtObject::DisplayLicense() ...@@ -434,7 +434,7 @@ void CoWowQtObject::DisplayLicense()
int CoWowQt::GetSelection(char* str, int size, const char* atom) int CoWowQt::GetSelection(char* str, int size, const char* atom)
{ {
debug_print("GetSelection str=%s, size=%d, arom=%s\n", str, size, atom); log_debug("GetSelection str=%s, size=%d, arom=%s\n", str, size, atom);
static wow_sSelection data; static wow_sSelection data;
data.received = 0; data.received = 0;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "co_cdh.h" #include "co_cdh.h"
#include "co_dcli.h" #include "co_dcli.h"
#include "co_debug.h" #include "co_log.h"
#include "co_string.h" #include "co_string.h"
#include "co_time.h" #include "co_time.h"
...@@ -220,7 +220,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -220,7 +220,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
&& !((action == journal_eAction_PostPropertiesObject && !((action == journal_eAction_PostPropertiesObject
|| action == journal_eAction_PostPropertiesSelect) || action == journal_eAction_PostPropertiesSelect)
&& o == lock_object)) { && o == lock_object)) {
debug_print("Unfinished action, forced close\n"); log_debug("Unfinished action, forced close\n");
// Close prevoius action // Close prevoius action
poslist[current_idx].redo_pos = fp.tellp(); poslist[current_idx].redo_pos = fp.tellp();
fp << journal_cTag_Redo << " " << journal_eAction_No << " " << status << " " fp << journal_cTag_Redo << " " << journal_eAction_No << " " << status << " "
...@@ -230,7 +230,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -230,7 +230,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
status = journal_eStatus_Stored; status = journal_eStatus_Stored;
lock_object = 0; lock_object = 0;
debug_print("Store(F)x: %3d list: %3zd undo: %10d redo: %10d\n", log_debug("Store(F)x: %3d list: %3zd undo: %10d redo: %10d\n",
current_idx - 1, poslist.size() - 1, current_idx - 1, poslist.size() - 1,
(int)poslist[poslist.size() - 1].undo_pos, (int)poslist[poslist.size() - 1].undo_pos,
(int)poslist[poslist.size() - 1].redo_pos); (int)poslist[poslist.size() - 1].redo_pos);
...@@ -239,7 +239,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -239,7 +239,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
|| (status == journal_eStatus_AnteProperties && lock_object != o)) || (status == journal_eStatus_AnteProperties && lock_object != o))
&& (action == journal_eAction_PostPropertiesObject && (action == journal_eAction_PostPropertiesObject
|| action == journal_eAction_PostPropertiesSelect)) { || action == journal_eAction_PostPropertiesSelect)) {
debug_print("Interrupted action, reopening\n"); log_debug("Interrupted action, reopening\n");
// Open prevoius action // Open prevoius action
JournalPos up; JournalPos up;
...@@ -253,7 +253,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -253,7 +253,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
} }
while ((int)poslist.size() > current_idx) { while ((int)poslist.size() > current_idx) {
debug_print("Remove %zd\n", poslist.size() - 1); log_debug("Remove %zd\n", poslist.size() - 1);
poslist.pop_back(); poslist.pop_back();
} }
...@@ -286,7 +286,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -286,7 +286,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
} }
while ((int)poslist.size() > current_idx) { while ((int)poslist.size() > current_idx) {
debug_print("Remove %zd\n", poslist.size() - 1); log_debug("Remove %zd\n", poslist.size() - 1);
poslist.pop_back(); poslist.pop_back();
} }
...@@ -390,7 +390,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -390,7 +390,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
current_idx++; current_idx++;
debug_print("Store idx: %3d list: %3zd undo: %10d redo: %10d\n", log_debug("Store idx: %3d list: %3zd undo: %10d redo: %10d\n",
current_idx - 1, poslist.size() - 1, current_idx - 1, poslist.size() - 1,
(int)poslist[poslist.size() - 1].undo_pos, (int)poslist[poslist.size() - 1].undo_pos,
(int)poslist[poslist.size() - 1].redo_pos); (int)poslist[poslist.size() - 1].redo_pos);
...@@ -414,7 +414,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -414,7 +414,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
} }
while ((int)poslist.size() > current_idx) { while ((int)poslist.size() > current_idx) {
debug_print("Remov idx: %3d list: %3zd undo: %10d redo: %10d\n", 0, log_debug("Remov idx: %3d list: %3zd undo: %10d redo: %10d\n", 0,
poslist.size() - 1, (int)poslist[poslist.size() - 1].undo_pos, poslist.size() - 1, (int)poslist[poslist.size() - 1].undo_pos,
(int)poslist[poslist.size() - 1].redo_pos); (int)poslist[poslist.size() - 1].redo_pos);
poslist.pop_back(); poslist.pop_back();
...@@ -479,7 +479,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o) ...@@ -479,7 +479,7 @@ int GraphJournal::store(journal_eAction action, grow_tObject o)
poslist.push_back(up); poslist.push_back(up);
current_idx++; current_idx++;
debug_print("Store idx: %3d list: %3zd undo: %10d redo: %10d\n", log_debug("Store idx: %3d list: %3zd undo: %10d redo: %10d\n",
current_idx - 1, poslist.size() - 1, current_idx - 1, poslist.size() - 1,
(int)poslist[poslist.size() - 1].undo_pos, (int)poslist[poslist.size() - 1].undo_pos,
(int)poslist[poslist.size() - 1].redo_pos); (int)poslist[poslist.size() - 1].redo_pos);
...@@ -497,7 +497,7 @@ int GraphJournal::undo() ...@@ -497,7 +497,7 @@ int GraphJournal::undo()
if (current_idx == 0) if (current_idx == 0)
return 0; return 0;
debug_print("Undo idx: %3d list: %3zd undo: %10d redo: %10d\n", log_debug("Undo idx: %3d list: %3zd undo: %10d redo: %10d\n",
current_idx - 1, poslist.size() - 1, current_idx - 1, poslist.size() - 1,
(int)poslist[current_idx - 1].undo_pos, (int)poslist[current_idx - 1].undo_pos,
(int)poslist[current_idx - 1].redo_pos); (int)poslist[current_idx - 1].redo_pos);
...@@ -574,7 +574,7 @@ int GraphJournal::redo() ...@@ -574,7 +574,7 @@ int GraphJournal::redo()
if (current_idx >= (int)poslist.size()) if (current_idx >= (int)poslist.size())
return 0; return 0;
debug_print("Redo idx: %3d list: %3zd undo: %10d redo: %10d\n", current_idx, log_debug("Redo idx: %3d list: %3zd undo: %10d redo: %10d\n", current_idx,
poslist.size() - 1, (int)poslist[current_idx].undo_pos, poslist.size() - 1, (int)poslist[current_idx].undo_pos,
(int)poslist[current_idx].redo_pos); (int)poslist[current_idx].redo_pos);
...@@ -651,7 +651,7 @@ int GraphJournal::undo_delete_select() ...@@ -651,7 +651,7 @@ int GraphJournal::undo_delete_select()
grow_tObject prev; grow_tObject prev;
int sts; int sts;
debug_print("undo_delete_select\n"); log_debug("undo_delete_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
...@@ -694,7 +694,7 @@ int GraphJournal::store_undo_delete_select() ...@@ -694,7 +694,7 @@ int GraphJournal::store_undo_delete_select()
int sts; int sts;
char name[80]; char name[80];
debug_print("store_undo_delete_select\n"); log_debug("store_undo_delete_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = sel_count - 1; i >= 0; i--) { for (int i = sel_count - 1; i >= 0; i--) {
...@@ -719,7 +719,7 @@ int GraphJournal::store_redo_delete_select() ...@@ -719,7 +719,7 @@ int GraphJournal::store_redo_delete_select()
grow_tObject* sel_list; grow_tObject* sel_list;
int sel_count; int sel_count;
debug_print("store_redo_delete_select\n"); log_debug("store_redo_delete_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -741,7 +741,7 @@ int GraphJournal::redo_delete_select() ...@@ -741,7 +741,7 @@ int GraphJournal::redo_delete_select()
char line[100]; char line[100];
int tag; int tag;
debug_print("redo_delete_select\n"); log_debug("redo_delete_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
...@@ -770,7 +770,7 @@ int GraphJournal::undo_delete_object() ...@@ -770,7 +770,7 @@ int GraphJournal::undo_delete_object()
{ {
grow_tObject o; grow_tObject o;
debug_print("undo_delete_select\n"); log_debug("undo_delete_select\n");
grow_ObjectRead(graph->grow->ctx, (std::ifstream&)fp, &o); grow_ObjectRead(graph->grow->ctx, (std::ifstream&)fp, &o);
grow_Redraw(graph->grow->ctx); grow_Redraw(graph->grow->ctx);
...@@ -779,7 +779,7 @@ int GraphJournal::undo_delete_object() ...@@ -779,7 +779,7 @@ int GraphJournal::undo_delete_object()
int GraphJournal::store_undo_delete_object(grow_tObject o) int GraphJournal::store_undo_delete_object(grow_tObject o)
{ {
debug_print("store_undo_delete_object\n"); log_debug("store_undo_delete_object\n");
grow_ObjectSave(o, (std::ofstream&)fp, glow_eSaveMode_Edit); grow_ObjectSave(o, (std::ofstream&)fp, glow_eSaveMode_Edit);
return GE__SUCCESS; return GE__SUCCESS;
...@@ -789,7 +789,7 @@ int GraphJournal::store_redo_delete_object(grow_tObject o) ...@@ -789,7 +789,7 @@ int GraphJournal::store_redo_delete_object(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_redo_delete_object\n"); log_debug("store_redo_delete_object\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -803,7 +803,7 @@ int GraphJournal::redo_delete_object() ...@@ -803,7 +803,7 @@ int GraphJournal::redo_delete_object()
grow_tObject o; grow_tObject o;
int sts; int sts;
debug_print("redo_delete_object\n"); log_debug("redo_delete_object\n");
fp.getline(name, sizeof(name)); fp.getline(name, sizeof(name));
...@@ -820,7 +820,7 @@ int GraphJournal::undo_create_object() ...@@ -820,7 +820,7 @@ int GraphJournal::undo_create_object()
grow_tObject o; grow_tObject o;
int sts; int sts;
debug_print("undo_create_object\n"); log_debug("undo_create_object\n");
fp.getline(name, sizeof(name)); fp.getline(name, sizeof(name));
...@@ -835,7 +835,7 @@ int GraphJournal::store_undo_create_object(grow_tObject o) ...@@ -835,7 +835,7 @@ int GraphJournal::store_undo_create_object(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_undo_create_object\n"); log_debug("store_undo_create_object\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -847,7 +847,7 @@ int GraphJournal::redo_create_object() ...@@ -847,7 +847,7 @@ int GraphJournal::redo_create_object()
{ {
grow_tObject o; grow_tObject o;
debug_print("redo_create_object\n"); log_debug("redo_create_object\n");
grow_ObjectRead(graph->grow->ctx, (std::ifstream&)fp, &o); grow_ObjectRead(graph->grow->ctx, (std::ifstream&)fp, &o);
if (!o) if (!o)
...@@ -860,7 +860,7 @@ int GraphJournal::redo_create_object() ...@@ -860,7 +860,7 @@ int GraphJournal::redo_create_object()
int GraphJournal::store_redo_create_object(grow_tObject o) int GraphJournal::store_redo_create_object(grow_tObject o)
{ {
debug_print("store_redo_create_object\n"); log_debug("store_redo_create_object\n");
grow_ObjectSave(o, (std::ofstream&)fp, glow_eSaveMode_Edit); grow_ObjectSave(o, (std::ofstream&)fp, glow_eSaveMode_Edit);
return GE__SUCCESS; return GE__SUCCESS;
...@@ -874,7 +874,7 @@ int GraphJournal::undo_properties_select() ...@@ -874,7 +874,7 @@ int GraphJournal::undo_properties_select()
char name[80]; char name[80];
int sts; int sts;
debug_print("undo_properties_select\n"); log_debug("undo_properties_select\n");
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
sscanf(line, "%d", &tag); sscanf(line, "%d", &tag);
...@@ -903,7 +903,7 @@ int GraphJournal::store_properties_select() ...@@ -903,7 +903,7 @@ int GraphJournal::store_properties_select()
int sel_count; int sel_count;
char name[80]; char name[80];
debug_print("store_properties_select\n"); log_debug("store_properties_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -925,7 +925,7 @@ int GraphJournal::undo_properties_object() ...@@ -925,7 +925,7 @@ int GraphJournal::undo_properties_object()
char name[80]; char name[80];
int sts; int sts;
debug_print("undo_properties_object\n"); log_debug("undo_properties_object\n");
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
sscanf(line, "%d", &tag); sscanf(line, "%d", &tag);
...@@ -956,7 +956,7 @@ int GraphJournal::store_properties_object(grow_tObject o) ...@@ -956,7 +956,7 @@ int GraphJournal::store_properties_object(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_properties_object\n"); log_debug("store_properties_object\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -975,7 +975,7 @@ int GraphJournal::undo_group_select() ...@@ -975,7 +975,7 @@ int GraphJournal::undo_group_select()
int tag; int tag;
int sts; int sts;
debug_print("undo_group_select\n"); log_debug("undo_group_select\n");
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
sscanf(line, "%d", &tag); sscanf(line, "%d", &tag);
...@@ -1001,7 +1001,7 @@ int GraphJournal::store_undo_group_select(grow_tObject o) ...@@ -1001,7 +1001,7 @@ int GraphJournal::store_undo_group_select(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_undo_group_select\n"); log_debug("store_undo_group_select\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -1017,7 +1017,7 @@ int GraphJournal::store_redo_group_select() ...@@ -1017,7 +1017,7 @@ int GraphJournal::store_redo_group_select()
grow_tObject* sel_list; grow_tObject* sel_list;
int sel_count; int sel_count;
debug_print("store_redo_group_select\n"); log_debug("store_redo_group_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -1043,7 +1043,7 @@ int GraphJournal::redo_group_select() ...@@ -1043,7 +1043,7 @@ int GraphJournal::redo_group_select()
grow_tObject group; grow_tObject group;
GeDyn* data; GeDyn* data;
debug_print("redo_group_select\n"); log_debug("redo_group_select\n");
grow_SelectClear(graph->grow->ctx); grow_SelectClear(graph->grow->ctx);
...@@ -1168,7 +1168,7 @@ int GraphJournal::store_undo_ungroup_select() ...@@ -1168,7 +1168,7 @@ int GraphJournal::store_undo_ungroup_select()
grow_tObject* member_list; grow_tObject* member_list;
int member_count; int member_count;
debug_print("store_undo_ungroup_select\n"); log_debug("store_undo_ungroup_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -1200,7 +1200,7 @@ int GraphJournal::store_redo_ungroup_select() ...@@ -1200,7 +1200,7 @@ int GraphJournal::store_redo_ungroup_select()
grow_tObject* sel_list; grow_tObject* sel_list;
int sel_count; int sel_count;
debug_print("store_redo_ungroup_select\n"); log_debug("store_redo_ungroup_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -1224,7 +1224,7 @@ int GraphJournal::redo_ungroup_select() ...@@ -1224,7 +1224,7 @@ int GraphJournal::redo_ungroup_select()
int tag; int tag;
int sts; int sts;
debug_print("redo_ungroup_select\n"); log_debug("redo_ungroup_select\n");
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
sscanf(line, "%d", &tag); sscanf(line, "%d", &tag);
...@@ -1252,7 +1252,7 @@ int GraphJournal::undo_paste() ...@@ -1252,7 +1252,7 @@ int GraphJournal::undo_paste()
char line[100]; char line[100];
int tag; int tag;
debug_print("undo_paste\n"); log_debug("undo_paste\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
...@@ -1282,7 +1282,7 @@ int GraphJournal::store_undo_paste() ...@@ -1282,7 +1282,7 @@ int GraphJournal::store_undo_paste()
grow_tObject* move_list; grow_tObject* move_list;
int move_count; int move_count;
debug_print("store_undo_paste\n"); log_debug("store_undo_paste\n");
grow_GetMoveList(graph->grow->ctx, &move_list, &move_count); grow_GetMoveList(graph->grow->ctx, &move_list, &move_count);
for (int i = 0; i < move_count; i++) { for (int i = 0; i < move_count; i++) {
...@@ -1303,7 +1303,7 @@ int GraphJournal::redo_paste() ...@@ -1303,7 +1303,7 @@ int GraphJournal::redo_paste()
char line[100]; char line[100];
int tag; int tag;
debug_print("redo_paste\n"); log_debug("redo_paste\n");
fp.getline(line, sizeof(line)); fp.getline(line, sizeof(line));
sscanf(line, "%d", &tag); sscanf(line, "%d", &tag);
...@@ -1326,7 +1326,7 @@ int GraphJournal::redo_paste() ...@@ -1326,7 +1326,7 @@ int GraphJournal::redo_paste()
int GraphJournal::store_redo_paste() int GraphJournal::store_redo_paste()
{ {
debug_print("store_redo_paste\n"); log_debug("store_redo_paste\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
for (int i = 0; i < (int)pastelist.size(); i++) { for (int i = 0; i < (int)pastelist.size(); i++) {
...@@ -1351,7 +1351,7 @@ int GraphJournal::undo_pop_select() ...@@ -1351,7 +1351,7 @@ int GraphJournal::undo_pop_select()
int tag; int tag;
int sts; int sts;
debug_print("undo_pop_select\n"); log_debug("undo_pop_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
...@@ -1392,7 +1392,7 @@ int GraphJournal::store_undo_pop_select() ...@@ -1392,7 +1392,7 @@ int GraphJournal::store_undo_pop_select()
grow_tObject next; grow_tObject next;
int sts; int sts;
debug_print("store_undo_pop_select\n"); log_debug("store_undo_pop_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = sel_count - 1; i >= 0; i--) { for (int i = sel_count - 1; i >= 0; i--) {
...@@ -1418,7 +1418,7 @@ int GraphJournal::store_redo_pop_select() ...@@ -1418,7 +1418,7 @@ int GraphJournal::store_redo_pop_select()
grow_tObject* sel_list; grow_tObject* sel_list;
int sel_count; int sel_count;
debug_print("store_redo_pop_select\n"); log_debug("store_redo_pop_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -1439,7 +1439,7 @@ int GraphJournal::redo_pop_select() ...@@ -1439,7 +1439,7 @@ int GraphJournal::redo_pop_select()
char line[100]; char line[100];
int tag; int tag;
debug_print("redo_pop_select\n"); log_debug("redo_pop_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
grow_SelectClear(graph->grow->ctx); grow_SelectClear(graph->grow->ctx);
...@@ -1477,7 +1477,7 @@ int GraphJournal::undo_push_select() ...@@ -1477,7 +1477,7 @@ int GraphJournal::undo_push_select()
int tag; int tag;
int sts; int sts;
debug_print("undo_push_select\n"); log_debug("undo_push_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
...@@ -1518,7 +1518,7 @@ int GraphJournal::store_undo_push_select() ...@@ -1518,7 +1518,7 @@ int GraphJournal::store_undo_push_select()
grow_tObject next; grow_tObject next;
int sts; int sts;
debug_print("store_undo_push_select\n"); log_debug("store_undo_push_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = sel_count - 1; i >= 0; i--) { for (int i = sel_count - 1; i >= 0; i--) {
...@@ -1544,7 +1544,7 @@ int GraphJournal::store_redo_push_select() ...@@ -1544,7 +1544,7 @@ int GraphJournal::store_redo_push_select()
grow_tObject* sel_list; grow_tObject* sel_list;
int sel_count; int sel_count;
debug_print("store_redo_push_select\n"); log_debug("store_redo_push_select\n");
grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count); grow_GetSelectList(graph->grow->ctx, &sel_list, &sel_count);
for (int i = 0; i < sel_count; i++) { for (int i = 0; i < sel_count; i++) {
...@@ -1565,7 +1565,7 @@ int GraphJournal::redo_push_select() ...@@ -1565,7 +1565,7 @@ int GraphJournal::redo_push_select()
char line[100]; char line[100];
int tag; int tag;
debug_print("redo_push_select\n"); log_debug("redo_push_select\n");
grow_SetNodraw(graph->grow->ctx); grow_SetNodraw(graph->grow->ctx);
grow_SelectClear(graph->grow->ctx); grow_SelectClear(graph->grow->ctx);
...@@ -1602,7 +1602,7 @@ int GraphJournal::undo_rename() ...@@ -1602,7 +1602,7 @@ int GraphJournal::undo_rename()
int tag; int tag;
int sts; int sts;
debug_print("undo_rename\n"); log_debug("undo_rename\n");
fp.getline(name_new, sizeof(name_new)); fp.getline(name_new, sizeof(name_new));
fp.getline(name_old, sizeof(name_old)); fp.getline(name_old, sizeof(name_old));
...@@ -1624,7 +1624,7 @@ int GraphJournal::store_undo_rename(grow_tObject o) ...@@ -1624,7 +1624,7 @@ int GraphJournal::store_undo_rename(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_undo_rename\n"); log_debug("store_undo_rename\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -1639,7 +1639,7 @@ int GraphJournal::store_redo_rename(grow_tObject o) ...@@ -1639,7 +1639,7 @@ int GraphJournal::store_redo_rename(grow_tObject o)
{ {
char name[80]; char name[80];
debug_print("store_redo_rename\n"); log_debug("store_redo_rename\n");
grow_GetObjectName(o, name, sizeof(name), glow_eName_Object); grow_GetObjectName(o, name, sizeof(name), glow_eName_Object);
...@@ -1659,7 +1659,7 @@ int GraphJournal::redo_rename() ...@@ -1659,7 +1659,7 @@ int GraphJournal::redo_rename()
int tag; int tag;
int sts; int sts;
debug_print("redo_rename\n"); log_debug("redo_rename\n");
fp.getline(name_new, sizeof(name_new)); fp.getline(name_new, sizeof(name_new));
fp.getline(name_old, sizeof(name_old)); fp.getline(name_old, sizeof(name_old));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment