Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
8232b1e3
Commit
8232b1e3
authored
Feb 07, 2019
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed co_debug to co_log, added optional logging to file and multiple logging levels.
parent
2e643250
Changes
20
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
148 additions
and
106 deletions
+148
-106
profibus/exe/profinet_viewer/qt/profinet_viewer_qt.cpp
profibus/exe/profinet_viewer/qt/profinet_viewer_qt.cpp
+1
-1
profibus/lib/wb/qt/wb_c_pndevice_qt.cpp
profibus/lib/wb/qt/wb_c_pndevice_qt.cpp
+5
-8
sev/exe/sev_xtt/qt/sev_xtt_qt.cpp
sev/exe/sev_xtt/qt/sev_xtt_qt.cpp
+1
-1
src/lib/co/src/co_dcli_file.cpp
src/lib/co/src/co_dcli_file.cpp
+3
-3
src/lib/co/src/co_log.cpp
src/lib/co/src/co_log.cpp
+50
-13
src/lib/co/src/co_log.h
src/lib/co/src/co_log.h
+15
-5
src/lib/co/src/co_smart_ptr.h
src/lib/co/src/co_smart_ptr.h
+0
-2
src/tools/bld/src/os_linux/hw_x86_64/variables.mk
src/tools/bld/src/os_linux/hw_x86_64/variables.mk
+1
-1
wb/exe/wb/qt/wb_qt.cpp
wb/exe/wb/qt/wb_qt.cpp
+2
-2
wb/exe/wb_cmd/qt/wb_cmd_qt.cpp
wb/exe/wb_cmd/qt/wb_cmd_qt.cpp
+2
-2
wb/lib/wb/qt/wb_wnav_qt.cqt
wb/lib/wb/qt/wb_wnav_qt.cqt
+4
-4
xtt/exe/co_help/qt/co_help_qt.cpp
xtt/exe/co_help/qt/co_help_qt.cpp
+2
-2
xtt/exe/pwr_rtmon/qt/pwr_rtmon_qt.cpp
xtt/exe/pwr_rtmon/qt/pwr_rtmon_qt.cpp
+2
-2
xtt/exe/rt_statusmon/qt/rt_statusmon_qt.cpp
xtt/exe/rt_statusmon/qt/rt_statusmon_qt.cpp
+2
-2
xtt/exe/rt_xtt/qt/rt_xtt_qt.cqt
xtt/exe/rt_xtt/qt/rt_xtt_qt.cqt
+2
-2
xtt/exe/rt_xtt_cmd/qt/rt_xtt_cmd_qt.cpp
xtt/exe/rt_xtt_cmd/qt/rt_xtt_cmd_qt.cpp
+2
-2
xtt/exe/wb_ge/qt/wb_ge_qt.cpp
xtt/exe/wb_ge/qt/wb_ge_qt.cpp
+2
-2
xtt/lib/cow/qt/cow_qt_helpers.h
xtt/lib/cow/qt/cow_qt_helpers.h
+1
-1
xtt/lib/cow/qt/cow_wow_qt.cqt
xtt/lib/cow/qt/cow_wow_qt.cqt
+1
-1
xtt/lib/ge/src/ge_graph_journal.cpp
xtt/lib/ge/src/ge_graph_journal.cpp
+50
-50
No files found.
profibus/exe/profinet_viewer/qt/profinet_viewer_qt.cpp
View file @
8232b1e3
...
...
@@ -55,7 +55,7 @@ int main(int argc, char* argv[])
int
sts
;
char
dev_name
[
20
]
=
"eth1"
;
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
QApplication
app
(
argc
,
argv
);
QApplication
::
setStyle
(
new
PwrStyle
());
...
...
profibus/lib/wb/qt/wb_c_pndevice_qt.cpp
View file @
8232b1e3
...
...
@@ -228,15 +228,14 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData
*
data
=
new
GsdmlDeviceData
();
sts
=
data
->
read
(
datafile
);
if
(
EVEN
(
sts
))
{
if
(
EVEN
(
sts
))
{
delete
data
;
return
sts
;
}
sts
=
data
->
get_value
(
Attr
,
Buf
,
BufSize
);
delete
data
;
return
sts
;
}
...
...
@@ -251,19 +250,17 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData
*
data
=
new
GsdmlDeviceData
();
sts
=
data
->
read
(
datafile
);
if
(
EVEN
(
sts
))
{
if
(
EVEN
(
sts
))
{
delete
data
;
return
sts
;
}
sts
=
data
->
modify_value
(
Attr
,
Value
);
if
(
ODD
(
sts
))
{
if
(
ODD
(
sts
))
{
data
->
print
(
datafile
);
}
delete
data
;
return
sts
;
}
...
...
sev/exe/sev_xtt/qt/sev_xtt_qt.cpp
View file @
8232b1e3
...
...
@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
unsigned
int
itemcnt
;
char
servername
[
40
]
=
""
;
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
// Get options
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
...
...
src/lib/co/src/co_dcli_file.cpp
View file @
8232b1e3
...
...
@@ -43,7 +43,7 @@
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_dcli_msg.h"
#include "co_
debu
g.h"
#include "co_
lo
g.h"
#include "co_string.h"
typedef
enum
{
...
...
@@ -175,7 +175,7 @@ int dcli_replace_env(const char* str, char* newstr)
if
((
value
=
getenv
(
lower_symbol
))
==
NULL
)
{
/* It was no symbol */
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
++
;
...
...
@@ -207,7 +207,7 @@ int dcli_replace_env(const char* str, char* newstr)
if
((
value
=
getenv
(
lower_symbol
))
==
NULL
)
{
/* It was no symbol */
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
;
}
else
{
...
...
src/lib/co/src/co_
debu
g.cpp
→
src/lib/co/src/co_
lo
g.cpp
View file @
8232b1e3
...
...
@@ -34,47 +34,84 @@
* General Public License plus this exception.
*/
#include "co_
debu
g.h"
#include "co_
lo
g.h"
#include <stdarg.h>
#include <string.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
)
{
time_t
t
;
struct
tm
*
tm
;
char
Date
[
11
],
Time
[
11
];
time
(
&
t
);
tm
=
localtime
(
&
t
);
time
_t
t
=
time
(
NULL
);
struct
tm
*
lt
=
localtime
(
&
t
);
if
(
fulldate
)
{
strftime
(
Date
,
11
,
"%Y-%m-%d"
,
tm
);
strftime
(
Date
,
11
,
"%Y-%m-%d"
,
lt
);
fprintf
(
stream
,
"%s "
,
Date
);
}
strftime
(
Time
,
11
,
"%H:%M:%S"
,
tm
);
strftime
(
Time
,
11
,
"%H:%M:%S"
,
lt
);
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
print_time
(
stderr
);
// 2. print filename only, without path
const
char
*
file2
=
strrchr
(
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
va_list
args
;
va_start
(
args
,
fmt
);
vfprintf
(
stderr
,
fmt
,
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
src/lib/co/src/co_
debu
g.h
→
src/lib/co/src/co_
lo
g.h
View file @
8232b1e3
...
...
@@ -36,16 +36,26 @@
// TODO: The functionality of this file overlaps that of rt_errh.
#ifndef CO_
DEBUG
#define CO_
DEBUG
#ifndef CO_
LOG_H
#define CO_
LOG_H
#include <stdarg.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
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
\ No newline at end of file
src/lib/co/src/co_smart_ptr.h
View file @
8232b1e3
...
...
@@ -39,8 +39,6 @@
#ifndef CO_UNIQUE_PTR
#define CO_UNIQUE_PTR
#include "co_debug.h"
// std::unique_ptr for single objects -> free memory with 'delete'
template
<
typename
T
>
class
unique_ptr
{
...
...
src/tools/bld/src/os_linux/hw_x86_64/variables.mk
View file @
8232b1e3
...
...
@@ -200,7 +200,7 @@ mkdir := mkdir
# Set to /buildversion for frozen dbs versions
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)
cflags
:=
$(cross_compile)
-c
-O3
-D_GNU_SOURCE
-DPWR_NDEBUG
-D_REENTRANT
-fPIC
$(warnings)
...
...
wb/exe/wb/qt/wb_qt.cpp
View file @
8232b1e3
...
...
@@ -78,7 +78,7 @@ WVsel* WbQt::vsel_new(pwr_tStatus* status, const char* name,
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
if
(
argc
>=
2
&&
streq
(
argv
[
1
],
"-m"
))
{
wb_erep
::
printMethods
();
exit
(
0
);
...
...
@@ -126,7 +126,7 @@ WbQt::WbQt(int argc, char* argv[])
strcpy
(
volumename
,
"directory"
);
sw_projectvolume
=
1
;
arg_cnt
=
0
;
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
if
(
argv
[
i
][
0
]
==
'-'
)
{
...
...
wb/exe/wb_cmd/qt/wb_cmd_qt.cpp
View file @
8232b1e3
...
...
@@ -40,7 +40,7 @@
#include <stdlib.h>
#include <string.h>
#include "co_
debu
g.h"
#include "co_
lo
g.h"
#include "cow_style_qt.h"
...
...
@@ -79,7 +79,7 @@ CmdQt::CmdQt(int argc, char* argv[])
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
QApplication
app
(
argc
,
argv
);
QApplication
::
setStyle
(
new
PwrStyle
());
new
CmdQt
(
argc
,
argv
);
...
...
wb/lib/wb/qt/wb_wnav_qt.cqt
View file @
8232b1e3
...
...
@@ -436,16 +436,16 @@ WAttText* WNavQt::watttext_new(
void WNavQt::wge_subwindow_loop(WGe* wge)
{
debug_print
(" before wge_subwindow_loop\n");
log_debug
(" before wge_subwindow_loop\n");
QApplication::exec();
debug_print
(" after wge_subwindow_loop\n");
log_debug
(" after wge_subwindow_loop\n");
}
void WNavQt::wge_modal_loop(WGe* wge)
{
debug_print
(" before wge_modal_loop\n");
log_debug
(" before wge_modal_loop\n");
QApplication::exec();
debug_print
(" after wge_modal_loop\n");
log_debug
(" after wge_modal_loop\n");
}
void WNavQt::message_dialog(char* title, char* text)
...
...
xtt/exe/co_help/qt/co_help_qt.cpp
View file @
8232b1e3
...
...
@@ -56,7 +56,7 @@ void close_cb(void* ctx, void* xhelp)
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
int
sts
;
QApplication
app
(
argc
,
argv
);
...
...
@@ -80,7 +80,7 @@ CoHelpQt::CoHelpQt(int argc, char* argv[], int* return_sts)
{
pwr_tStatus
sts
;
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
}
...
...
xtt/exe/pwr_rtmon/qt/pwr_rtmon_qt.cpp
View file @
8232b1e3
...
...
@@ -71,11 +71,11 @@ static void rtmon_close_cb(void* ctx)
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
int
sts
;
char
display
[
80
]
=
""
;
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
if
(
streq
(
argv
[
i
],
"-h"
))
{
...
...
xtt/exe/rt_statusmon/qt/rt_statusmon_qt.cpp
View file @
8232b1e3
...
...
@@ -71,13 +71,13 @@ static void statusmon_close(void* ctx)
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
int
sts
;
int
mode
=
nodelist_eMode_SystemStatus
;
int
view_descr
=
0
;
char
language
[
20
]
=
""
;
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
if
(
streq
(
argv
[
i
],
"-h"
))
{
...
...
xtt/exe/rt_xtt/qt/rt_xtt_qt.cqt
View file @
8232b1e3
...
...
@@ -551,7 +551,7 @@ void XttQtWidget::valchanged_cmd_entry()
int main(int argc, char* argv[])
{
setDebug(1
);
log_setLevel(LOG_TRACE
);
int sts;
QApplication app(argc, argv);
...
...
@@ -598,7 +598,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts)
strcat(title, nodename);
}
debug_print
("%s ", argv[0]);
log_debug
("%s ", argv[0]);
for (int i = 1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]);
}
...
...
xtt/exe/rt_xtt_cmd/qt/rt_xtt_cmd_qt.cpp
View file @
8232b1e3
...
...
@@ -73,7 +73,7 @@ static int timeout_func()
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
pwr_tStatus
sts
;
int
i
;
char
str
[
256
];
...
...
@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
/* If arguments, treat them as a command and then exit */
// Open directory volume as default
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
str
[
0
]
=
0
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
...
...
xtt/exe/wb_ge/qt/wb_ge_qt.cpp
View file @
8232b1e3
...
...
@@ -64,7 +64,7 @@ static void usage()
int
main
(
int
argc
,
char
*
argv
[])
{
setDebug
(
1
);
log_setLevel
(
LOG_TRACE
);
int
i
;
pwr_tFileName
file
;
char
graph_name
[
80
];
...
...
@@ -88,7 +88,7 @@ int main(int argc, char* argv[])
CoXHelpQt
*
xhelp
=
new
CoXHelpQt
(
0
,
xhelp_eUtility_Wtt
,
&
sts
);
CoXHelpQt
::
set_default
(
xhelp
);
debug_print
(
"%s "
,
argv
[
0
]);
log_debug
(
"%s "
,
argv
[
0
]);
if
(
argc
>
1
)
{
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
fprintf
(
stderr
,
"%s "
,
argv
[
i
]);
...
...
xtt/lib/cow/qt/cow_qt_helpers.h
View file @
8232b1e3
...
...
@@ -37,7 +37,7 @@
#ifndef QT_HELPERS_H
#define QT_HELPERS_H
#include "co_
debu
g.h"
#include "co_
lo
g.h"
#include <QAction>
#include <QComboBox>
...
...
xtt/lib/cow/qt/cow_wow_qt.cqt
View file @
8232b1e3
...
...
@@ -434,7 +434,7 @@ void CoWowQtObject::DisplayLicense()
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;
data.received = 0;
...
...
xtt/lib/ge/src/ge_graph_journal.cpp
View file @
8232b1e3
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment