Daniele Bartolini 9 rokov pred
rodič
commit
0066b6890f

+ 18 - 0
src/core/error/callstack.h

@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2012-2017 Daniele Bartolini and individual contributors.
+ * License: https://github.com/taylor001/crown/blob/master/LICENSE
+ */
+
+#pragma once
+
+#include "string_types.h"
+
+namespace crown
+{
+namespace error
+{
+	/// Fills @a ss with the current call stack.
+	void callstack(StringStream& ss);
+
+} // namespace error
+} // namespace crown

+ 4 - 4
src/core/error/callstack_android.cpp

@@ -3,19 +3,19 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "config.h"
+#include "platform.h"
 
 #if CROWN_PLATFORM_ANDROID
 
-#include "log.h"
+#include "string_stream.h"
 
 namespace crown
 {
 namespace error
 {
-	void print_callstack()
+	void callstack(StringStream& ss)
 	{
-		loge("\tNot supported.");
+		ss << "Not supported";
 	}
 } // namespace error
 

+ 12 - 7
src/core/error/callstack_linux.cpp

@@ -3,11 +3,11 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "config.h"
+#include "platform.h"
 
 #if CROWN_PLATFORM_LINUX && CROWN_COMPILER_GCC
 
-#include "log.h"
+#include "string_stream.h"
 #include "string_utils.h"
 #include <cxxabi.h>
 #include <execinfo.h>
@@ -34,7 +34,7 @@ namespace error
 		return "<addr2line missing>";
 	}
 
-	void print_callstack()
+	void callstack(StringStream& ss)
 	{
 		void* array[64];
 		int size = backtrace(array, countof(array));
@@ -50,7 +50,9 @@ namespace error
 			char* addr_begin   = strchr(msg, '[');
 			char* addr_end     = strchr(msg, ']');
 
-			// if the line could be processed, attempt to demangle the symbol
+			char buf[512];
+
+			// Attempt to demangle the symbol
 			if (mangled_name && offset_begin && offset_end && mangled_name < offset_begin)
 			{
 				*mangled_name++ = '\0';
@@ -64,7 +66,9 @@ namespace error
 				char line[256];
 				memset(line, 0, sizeof(line));
 
-				logi("\t[%2d] %s: (%s)+%s in %s"
+				snprintf(buf
+					, sizeof(buf)
+					, "    [%2d] %s: (%s)+%s in %s\n"
 					, i
 					, msg
 					, (demangle_ok == 0 ? real_name : mangled_name)
@@ -74,11 +78,12 @@ namespace error
 
 				free(real_name);
 			}
-			// otherwise, print the whole line
 			else
 			{
-				logi("\t[%2d] %s", i, msg);
+				snprintf(buf, sizeof(buf), "    [%2d] %s\n", i, msg);
 			}
+
+			ss << buf;
 		}
 		free(messages);
 	}

+ 25 - 5
src/core/error/callstack_windows.cpp

@@ -3,11 +3,11 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "config.h"
+#include "platform.h"
 
 #if CROWN_PLATFORM_WINDOWS
 
-#include "log.h"
+#include "string_stream.h"
 #include <windows.h>
 #include <dbghelp.h>
 
@@ -15,7 +15,7 @@ namespace crown
 {
 namespace error
 {
-	void print_callstack()
+	void callstack(StringStream& ss)
 	{
 		SymInitialize(GetCurrentProcess(), NULL, TRUE);
 		SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
@@ -79,10 +79,30 @@ namespace error
 						);
 			res = res && SymFromAddr(GetCurrentProcess(), stack.AddrPC.Offset, 0, sym);
 
+			char buf[512]
+
 			if (res == TRUE)
-				logi("\t[%2i] %s in %s:%d", num, sym->Name, line.FileName, line.LineNumber);
+			{
+				snprintf(buf
+					, sizeof(buf)
+					, "    [%2i] %s in %s:%d"
+					, num
+					, sym->Name
+					, line.FileName
+					, line.LineNumber
+					);
+			}
 			else
-				logi("\t[%2i] 0x%p", num, stack.AddrPC.Offset);
+			{
+				snprintf(buf
+					, sizeof(buf)
+					, "    [%2i] 0x%p"
+					, num
+					, stack.AddrPC.Offset
+					);
+			}
+
+			ss << buf;
 		}
 
 		SymCleanup(GetCurrentProcess());

+ 14 - 6
src/core/error/error.cpp

@@ -3,28 +3,36 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
+#include "callstack.h"
 #include "error.h"
 #include "log.h"
+#include "string_stream.h"
+#include "temp_allocator.h"
 #include <stdarg.h>
 #include <stdlib.h> // exit
 
+namespace { const crown::log_internal::System ERROR = { "Error" }; }
+
 namespace crown
 {
 namespace error
 {
-	static void abort(const char* file, int line, const char* format, va_list args)
+	static void abort(const char* format, va_list args)
 	{
-		logev(format, args);
-		loge("\tIn: %s:%d\n\nStacktrace:", file, line);
-		print_callstack();
+		logev(ERROR, format, args);
+
+		TempAllocator4096 ta;
+		StringStream ss(ta);
+		callstack(ss);
+		loge(ERROR, "Stacktrace:\n%s", string_stream::c_str(ss));
 		exit(EXIT_FAILURE);
 	}
 
-	void abort(const char* file, int line, const char* format, ...)
+	void abort(const char* format, ...)
 	{
 		va_list args;
 		va_start(args, format);
-		abort(file, line, format, args);
+		abort(format, args);
 		va_end(args);
 	}
 } // namespace error

+ 15 - 15
src/core/error/error.h

@@ -18,27 +18,27 @@ namespace error
 {
 	/// Aborts the program execution logging an error message and the stacktrace if
 	/// the platform supports it.
-	void abort(const char* file, int line, const char* format, ...);
+	void abort(const char* format, ...);
 
-	/// Prints the current call stack.
-	void print_callstack();
 } // namespace error
 
 } // namespace crown
 
 #if CROWN_DEBUG
-	#define CE_ASSERT(condition, msg, ...)                  \
-		do                                                  \
-		{                                                   \
-			if (!(condition))                               \
-			{                                               \
-				crown::error::abort(__FILE__                \
-					, __LINE__                              \
-					, "\nAssertion failed: %s\n\t" msg "\n" \
-					, #condition                            \
-					, ##__VA_ARGS__                         \
-					);                                      \
-			}                                               \
+	#define CE_ASSERT(condition, msg, ...)                   \
+		do                                                   \
+		{                                                    \
+			if (!(condition))                                \
+			{                                                \
+				crown::error::abort("Assertion failed: %s\n" \
+					"    In: %s:%d\n"                        \
+					"    " msg                               \
+					, # condition                            \
+					, __FILE__                               \
+					, __LINE__                               \
+					, ## __VA_ARGS__                         \
+					);                                       \
+			}                                                \
 		} while (0)
 #else
 	#define CE_ASSERT(...) ((void)0)

+ 0 - 2
src/device/console_api.cpp

@@ -38,9 +38,7 @@ static void console_command_reload(ConsoleServer& /*cs*/, TCPSocket /*client*/,
 	sjson::parse_string(obj["resource_type"], type);
 	sjson::parse_string(obj["resource_name"], name);
 
-	logi("Reloading resource '%s.%s'", name.c_str(), type.c_str());
 	device()->reload(ResourceId(type.c_str()), ResourceId(name.c_str()));
-	logi("Reloaded resource '%s.%s'", name.c_str(), type.c_str());
 }
 
 static void console_command_pause(ConsoleServer& /*cs*/, TCPSocket /*client*/, const char* /*json*/, void* /*user_data*/)

+ 17 - 5
src/device/device.cpp

@@ -59,6 +59,8 @@
 
 #define MAX_SUBSYSTEMS_HEAP 8 * 1024 * 1024
 
+namespace { const crown::log_internal::System DEVICE = { "Device" }; }
+
 namespace crown
 {
 extern bool next_event(OsEvent& ev);
@@ -77,7 +79,7 @@ struct BgfxCallback : public bgfx::CallbackI
 		char buf[2048];
 		strncpy(buf, _format, sizeof(buf));
 		buf[strlen32(buf)-1] = '\0'; // Remove trailing newline
-		logiv(buf, _argList);
+		logiv(DEVICE, buf, _argList);
 	}
 
 	virtual u32 cacheReadSize(u64 /*_id*/)
@@ -318,7 +320,7 @@ void Device::run()
 	_last_log = _bundle_filesystem->open(CROWN_LAST_LOG, FileOpenMode::WRITE);
 #endif // CROWN_PLATFORM_ANDROID
 
-	logi("Initializing Crown Engine %s...", version());
+	logi(DEVICE, "Initializing Crown Engine %s %s %s", version(), platform(), architecture());
 
 	profiler_globals::init();
 
@@ -399,7 +401,7 @@ void Device::run()
 	_lua_environment->execute((LuaResource*)_resource_manager->get(RESOURCE_TYPE_SCRIPT, _boot_config.boot_script_name));
 	_lua_environment->call_global("init", 0);
 
-	logi("Engine initialized");
+	logi(DEVICE, "Initialized");
 
 	s16 mouse_x = 0;
 	s16 mouse_y = 0;
@@ -499,13 +501,13 @@ void Device::quit()
 void Device::pause()
 {
 	_paused = true;
-	logi("Engine paused.");
+	logi(DEVICE, "Paused");
 }
 
 void Device::unpause()
 {
 	_paused = false;
-	logi("Engine unpaused.");
+	logi(DEVICE, "Unpaused");
 }
 
 void Device::resolution(u16& width, u16& height)
@@ -605,6 +607,14 @@ void Device::destroy_resource_package(ResourcePackage& rp)
 
 void Device::reload(StringId64 type, StringId64 name)
 {
+	TempAllocator64 ta;
+	DynamicString type_str(ta);
+	DynamicString name_str(ta);
+	type.to_string(type_str);
+	name.to_string(name_str);
+
+	logi(DEVICE, "Reloading #ID(%s-%s)", type_str.c_str(), name_str.c_str());
+
 	_resource_manager->reload(type, name);
 	const void* new_resource = _resource_manager->get(type, name);
 
@@ -612,6 +622,8 @@ void Device::reload(StringId64 type, StringId64 name)
 	{
 		_lua_environment->execute((const LuaResource*)new_resource);
 	}
+
+	logi(DEVICE, "Reloaded #ID(%s-%s)", type_str.c_str(), name_str.c_str());
 }
 
 void Device::log(const char* msg)

+ 6 - 3
src/device/log.cpp

@@ -19,7 +19,7 @@ namespace log_internal
 {
 	static Mutex s_mutex;
 
-	void logx(LogSeverity::Enum sev, const char* msg, va_list args)
+	void logx(LogSeverity::Enum sev, System system, const char* msg, va_list args)
 	{
 		ScopedMutex sm(s_mutex);
 
@@ -60,6 +60,9 @@ namespace log_internal
 			json << "\"severity\":\"";
 			json << s_severity_map[sev];
 			json << "\",";
+			json << "\"system\":\"";
+			json << system.name;
+			json << "\",";
 			json << "\"message\":\"";
 
 			// Sanitize buf
@@ -80,11 +83,11 @@ namespace log_internal
 			device()->log(buf);
 	}
 
-	void logx(LogSeverity::Enum sev, const char* msg, ...)
+	void logx(LogSeverity::Enum sev, System system, const char* msg, ...)
 	{
 		va_list args;
 		va_start(args, msg);
-		logx(sev, msg, args);
+		logx(sev, system, msg, args);
 		va_end(args);
 	}
 } // namespace log

+ 13 - 8
src/device/log.h

@@ -26,14 +26,19 @@ struct LogSeverity
 
 namespace log_internal
 {
-	void logx(LogSeverity::Enum sev, const char* msg, va_list args);
-	void logx(LogSeverity::Enum sev, const char* msg, ...);
+	struct System
+	{
+		const char* name;
+	};
+
+	void logx(LogSeverity::Enum sev, System system, const char* msg, va_list args);
+	void logx(LogSeverity::Enum sev, System system, const char* msg, ...);
 } // namespace log_internal
 } // namespace crown
 
-#define logiv(msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_INFO, msg, va_list)
-#define logev(msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_ERROR, msg, va_list)
-#define logwv(msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_WARN, msg, va_list)
-#define logi(msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_INFO, msg, ##__VA_ARGS__)
-#define loge(msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_ERROR, msg, ##__VA_ARGS__)
-#define logw(msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_WARN, msg, ##__VA_ARGS__)
+#define logiv(system, msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_INFO, system, msg, va_list)
+#define logev(system, msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_ERROR, system, msg, va_list)
+#define logwv(system, msg, va_list) crown::log_internal::logx(crown::LogSeverity::LOG_WARN, system, msg, va_list)
+#define logi(system, msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_INFO, system, msg, ## __VA_ARGS__)
+#define loge(system, msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_ERROR, system, msg, ## __VA_ARGS__)
+#define logw(system, msg, ...) crown::log_internal::logx(crown::LogSeverity::LOG_WARN, system, msg, ## __VA_ARGS__)

+ 3 - 1
src/lua/lua_environment.cpp

@@ -13,6 +13,8 @@
 #include "resource_manager.h"
 #include <stdarg.h>
 
+namespace { const crown::log_internal::System LUA = { "Lua" }; }
+
 namespace crown
 {
 extern void load_api(LuaEnvironment& env);
@@ -38,7 +40,7 @@ static int error_handler(lua_State* L)
 	lua_pushinteger(L, 2);
 	lua_call(L, 2, 1); // Call debug.traceback
 
-	loge(lua_tostring(L, -1)); // Print error message
+	loge(LUA, lua_tostring(L, -1)); // Print error message
 	lua_pop(L, 1); // Remove error message from stack
 	lua_pop(L, 1); // Remove debug.traceback from stack
 

+ 2 - 4
src/resource/compile_options.cpp

@@ -19,20 +19,18 @@
 
 namespace crown
 {
-CompileOptions::CompileOptions(DataCompiler& dc, Filesystem& bundle_fs, Buffer& output, const char* platform, jmp_buf* buf)
+CompileOptions::CompileOptions(DataCompiler& dc, Filesystem& bundle_fs, Buffer& output, const char* platform)
 	: _data_compiler(dc)
 	, _bundle_fs(bundle_fs)
 	, _output(output)
 	, _platform(platform)
-	, _jmpbuf(buf)
 	, _dependencies(default_allocator())
 {
 }
 
 void CompileOptions::error(const char* msg, va_list args)
 {
-	logev(msg, args);
-	longjmp(*_jmpbuf, 1);
+	_data_compiler.error(msg, args);
 }
 
 void CompileOptions::error(const char* msg, ...)

+ 1 - 3
src/resource/compile_options.h

@@ -9,7 +9,6 @@
 #include "container_types.h"
 #include "filesystem_types.h"
 #include "string_types.h"
-#include <setjmp.h>
 #include <stdarg.h>
 
 #define DATA_COMPILER_ASSERT(condition, opts, msg, ...) \
@@ -42,12 +41,11 @@ class CompileOptions
 	Filesystem& _bundle_fs;
 	Buffer& _output;
 	const char* _platform;
-	jmp_buf* _jmpbuf;
 	Vector<DynamicString> _dependencies;
 
 public:
 
-	CompileOptions(DataCompiler& dc, Filesystem& bundle_fs, Buffer& output, const char* platform, jmp_buf* buf);
+	CompileOptions(DataCompiler& dc, Filesystem& bundle_fs, Buffer& output, const char* platform);
 
 	void error(const char* msg, va_list args);
 

+ 31 - 26
src/resource/data_compiler.cpp

@@ -6,39 +6,39 @@
 #include "allocator.h"
 #include "compile_options.h"
 #include "config.h"
+#include "config_resource.h"
+#include "console_api.h"
 #include "console_server.h"
 #include "data_compiler.h"
+#include "device_options.h"
 #include "dynamic_string.h"
 #include "file.h"
 #include "filesystem_disk.h"
+#include "font_resource.h"
 #include "hash_map.h"
+#include "json_object.h"
+#include "level_resource.h"
 #include "log.h"
+#include "lua_resource.h"
 #include "map.h"
+#include "material_resource.h"
+#include "mesh_resource.h"
 #include "os.h"
+#include "package_resource.h"
 #include "path.h"
-#include "sjson.h"
-#include "string_stream.h"
-#include "temp_allocator.h"
-#include "vector.h"
-#include <setjmp.h>
-
-#include "resource_types.h"
-#include "config_resource.h"
-#include "font_resource.h"
-#include "lua_resource.h"
-#include "level_resource.h"
-#include "mesh_resource.h"
-#include "material_resource.h"
 #include "physics_resource.h"
-#include "package_resource.h"
-#include "sound_resource.h"
+#include "resource_types.h"
 #include "shader_resource.h"
+#include "sjson.h"
+#include "sound_resource.h"
 #include "sprite_resource.h"
+#include "string_stream.h"
+#include "temp_allocator.h"
 #include "texture_resource.h"
 #include "unit_resource.h"
-#include "device_options.h"
-#include "console_api.h"
-#include "json_object.h"
+#include "vector.h"
+
+namespace { const crown::log_internal::System COMPILER = { "Compiler" }; }
 
 namespace crown
 {
@@ -91,13 +91,13 @@ static void console_command_compile(ConsoleServer& cs, TCPSocket client, const c
 		cs.send(client, string_stream::c_str(ss));
 	}
 
-	logi("Compiling '%s'", id.c_str());
+	logi(COMPILER, "Compiling '%s'", id.c_str());
 	bool succ = ((DataCompiler*)user_data)->compile(data_dir.c_str(), platform.c_str());
 
 	if (succ)
-		logi("Compiled '%s'", id.c_str());
+		logi(COMPILER, "Compiled '%s'", id.c_str());
 	else
-		loge("Error while compiling '%s'", id.c_str());
+		loge(COMPILER, "Failed to compile '%s'", id.c_str());
 
 	{
 		TempAllocator512 ta;
@@ -274,23 +274,22 @@ bool DataCompiler::compile(FilesystemDisk& bundle_fs, const char* type, const ch
 
 	path::join(path, CROWN_DATA_DIRECTORY, dst_path.c_str());
 
-	logi("%s <= %s", dst_path.c_str(), src_path.c_str());
+	logi(COMPILER, "%s <= %s", dst_path.c_str(), src_path.c_str());
 
 	if (!can_compile(_type))
 	{
-		loge("Unknown resource type: '%s'", type);
+		loge(COMPILER, "Unknown resource type: '%s'", type);
 		return false;
 	}
 
 	bool success = true;
-	jmp_buf buf;
 
 	Buffer output(default_allocator());
 	array::reserve(output, 4*1024*1024);
 
-	if (!setjmp(buf))
+	if (!setjmp(_jmpbuf))
 	{
-		CompileOptions opts(*this, bundle_fs, output, platform, &buf);
+		CompileOptions opts(*this, bundle_fs, output, platform);
 
 		compile(_type, src_path.c_str(), opts);
 
@@ -450,6 +449,12 @@ u32 DataCompiler::version(StringId64 type)
 	return hash_map::get(_compilers, type, ResourceTypeData()).version;
 }
 
+void DataCompiler::error(const char* msg, va_list args)
+{
+	logev(COMPILER, msg, args);
+	longjmp(_jmpbuf, 1);
+}
+
 void DataCompiler::filemonitor_callback(FileMonitorEvent::Enum fme, bool is_dir, const char* path, const char* path_renamed)
 {
 	TempAllocator512 ta;

+ 4 - 0
src/resource/data_compiler.h

@@ -10,6 +10,7 @@
 #include "container_types.h"
 #include "file_monitor.h"
 #include "filesystem_disk.h"
+#include <setjmp.h>
 
 namespace crown
 {
@@ -30,6 +31,7 @@ class DataCompiler
 	Vector<DynamicString> _files;
 	Vector<DynamicString> _globs;
 	FileMonitor _file_monitor;
+	jmp_buf _jmpbuf;
 
 	void add_file(const char* path);
 	void add_tree(const char* path);
@@ -67,6 +69,8 @@ public:
 
 	// Returns the version of the compiler for @a type.
 	u32 version(StringId64 type);
+
+	void error(const char* msg, va_list args);
 };
 
 int main_data_compiler(int argc, char** argv);

+ 3 - 1
src/world/physics_world_bullet.cpp

@@ -46,6 +46,8 @@
 #include <LinearMath/btDefaultMotionState.h>
 #include <LinearMath/btIDebugDraw.h>
 
+namespace { const crown::log_internal::System PHYSICS = { "Physics" }; }
+
 namespace crown
 {
 namespace physics_globals
@@ -126,7 +128,7 @@ public:
 
 	void reportErrorWarning(const char* warningString)
 	{
-		logw(warningString);
+		logw(PHYSICS, warningString);
 	}
 
 	void draw3dText(const btVector3& /*location*/, const char* /*textString*/)

+ 7 - 5
src/world/sound_world_al.cpp

@@ -18,6 +18,8 @@
 #include <AL/al.h>
 #include <AL/alc.h>
 
+namespace { const crown::log_internal::System SOUND = { "Sound" }; }
+
 namespace crown
 {
 #if CROWN_DEBUG
@@ -50,16 +52,16 @@ namespace audio_globals
 	void init()
 	{
 		s_al_device = alcOpenDevice(NULL);
-		CE_ASSERT(s_al_device, "Cannot open OpenAL audio device");
+		CE_ASSERT(s_al_device, "alcOpenDevice: error");
 
 		s_al_context = alcCreateContext(s_al_device, NULL);
-		CE_ASSERT(s_al_context, "Cannot create OpenAL context");
+		CE_ASSERT(s_al_context, "alcCreateContext: error");
 
 		AL_CHECK(alcMakeContextCurrent(s_al_context));
 
-		logi("OpenAL Vendor   : %s", alGetString(AL_VENDOR));
-		logi("OpenAL Version  : %s", alGetString(AL_VERSION));
-		logi("OpenAL Renderer : %s", alGetString(AL_RENDERER));
+		logi(SOUND, "OpenAL Vendor   : %s", alGetString(AL_VENDOR));
+		logi(SOUND, "OpenAL Version  : %s", alGetString(AL_VERSION));
+		logi(SOUND, "OpenAL Renderer : %s", alGetString(AL_RENDERER));
 
 		AL_CHECK(alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED));
 		AL_CHECK(alDopplerFactor(1.0f));

+ 12 - 12
tools/level_editor/level_editor.vala

@@ -371,24 +371,24 @@ namespace Crown
 
 		private void on_compiler_connected()
 		{
-			_console_view.log("Compiler connected.", "info");
+			_console_view.log("Editor", "Compiler connected.", "info");
 			_compiler.receive_async();
 		}
 
 		private void on_compiler_disconnected()
 		{
-			_console_view.log("Compiler disconnected.", "info");
+			_console_view.log("Editor", "Compiler disconnected.", "info");
 		}
 
 		private void on_engine_connected()
 		{
-			_console_view.log("Engine connected.", "info");
+			_console_view.log("Editor", "Engine connected.", "info");
 			_engine.receive_async();
 		}
 
 		private void on_engine_disconnected()
 		{
-			_console_view.log("Engine disconnected.", "info");
+			_console_view.log("Editor", "Engine disconnected.", "info");
 		}
 
 		private static int stringcmp(ref string a, ref string b)
@@ -405,7 +405,7 @@ namespace Crown
 
 				if (msg_type == "message")
 				{
-					_console_view.log((string)msg["message"], (string)msg["severity"]);
+					_console_view.log((string)msg["system"], (string)msg["message"], (string)msg["severity"]);
 				}
 				else if (msg_type == "add_file")
 				{
@@ -515,7 +515,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 
 			// Receive next message
@@ -570,7 +570,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 
 			for (int tries = 0; !_compiler.is_connected() && tries < 5; ++tries)
@@ -636,7 +636,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 
 			for (int tries = 0; !_engine.is_connected() && tries < 5; ++tries)
@@ -691,7 +691,7 @@ namespace Crown
 					}
 					catch (Error e)
 					{
-						_console_view.log(e.message, "error");
+						_console_view.log("Editor", e.message, "error");
 					}
 				}
 			});
@@ -1232,7 +1232,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 		}
 
@@ -1244,7 +1244,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 		}
 
@@ -1257,7 +1257,7 @@ namespace Crown
 			}
 			catch (Error e)
 			{
-				_console_view.log(e.message, "error");
+				_console_view.log("Editor", e.message, "error");
 			}
 		}
 

+ 5 - 7
tools/widgets/console_view.vala

@@ -77,7 +77,7 @@ namespace Crown
 
 			// // Create tags for color-formatted text
 			Gtk.TextTag tag_info = new Gtk.TextTag("info");
-			tag_info.foreground_rgba = { 1.0, 1.0, 1.0, 1.0 };
+			tag_info.foreground_rgba = { 0.7, 0.7, 0.7, 1.0 };
 			Gtk.TextTag tag_warning = new Gtk.TextTag("warning");
 			tag_warning.foreground_rgba = { 1.0, 1.0, 0.4, 1.0 };
 			Gtk.TextTag tag_error = new Gtk.TextTag("error");
@@ -111,11 +111,11 @@ namespace Crown
 				if (words.length == 3)
 					_console_client.send(EngineApi.reload(words[1], words[2]));
 				else
-					log("Hint reload <type> <name>", "error");
+					log("Console View", "Hint reload <type> <name>", "error");
 			}
 			else
 			{
-				log("Unknown command: '%s'".printf(words[0]), "error");
+				log("Console View", "Unknown command: '%s'".printf(words[0]), "error");
 			}
 		}
 
@@ -135,8 +135,6 @@ namespace Crown
 			if (text.length > 0)
 			{
 				_entry_history.push(text);
-				log("> " + text, "info");
-
 				do_stuff(text);
 			}
 
@@ -155,9 +153,9 @@ namespace Crown
 			return true;
 		}
 
-		public void log(string text, string severity)
+		public void log(string system, string text, string severity)
 		{
-			string line = text + "\n";
+			string line = system + ": " + text + "\n";
 			Gtk.TextBuffer buffer = _text_view.buffer;
 			Gtk.TextIter end_iter;
 			buffer.get_end_iter(out end_iter);