summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2017-11-14 20:01:45 -0200
committerGeorge Marques <george@gmarqu.es>2017-11-16 21:56:57 -0200
commit1d12470a78d31a054aefc7f7c9a863db24b09986 (patch)
treed020f85566491ff2975bf8084a8ad68f8b66d9ee /core
parentb44cb4e3b9b573a3cbbd6f71aff81e6c3465d84b (diff)
Add print_error function, akin to print_line
Diffstat (limited to 'core')
-rw-r--r--core/print_string.cpp20
-rw-r--r--core/print_string.h3
-rw-r--r--core/script_debugger_remote.cpp2
-rw-r--r--core/script_debugger_remote.h2
4 files changed, 23 insertions, 4 deletions
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 92a04cbf0b..520fb3daec 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -82,7 +82,25 @@ void print_line(String p_string) {
PrintHandlerList *l = print_handler_list;
while (l) {
- l->printfunc(l->userdata, p_string);
+ l->printfunc(l->userdata, p_string, false);
+ l = l->next;
+ }
+
+ _global_unlock();
+}
+
+void print_error(String p_string) {
+
+ if (!_print_error_enabled)
+ return;
+
+ OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data());
+
+ _global_lock();
+ PrintHandlerList *l = print_handler_list;
+ while (l) {
+
+ l->printfunc(l->userdata, p_string, true);
l = l->next;
}
diff --git a/core/print_string.h b/core/print_string.h
index 9f8420c31a..6b68380b9d 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -34,7 +34,7 @@
extern void (*_print_func)(String);
-typedef void (*PrintHandlerFunc)(void *, const String &p_string);
+typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error);
struct PrintHandlerList {
@@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler);
extern bool _print_line_enabled;
extern bool _print_error_enabled;
extern void print_line(String p_string);
+extern void print_error(String p_string);
#endif
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index f77fb116c7..5655a4d5e4 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -832,7 +832,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
mutex->unlock();
}
-void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) {
+void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) {
ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this;
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 22137d1350..90d2daf1f8 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
uint64_t msec_count;
bool locking; //hack to avoid a deadloop
- static void _print_handler(void *p_this, const String &p_string);
+ static void _print_handler(void *p_this, const String &p_string, bool p_error);
PrintHandlerList phl;