about summary refs log tree commit diff
path: root/src/engine/shared/console.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/shared/console.cpp')
-rw-r--r--src/engine/shared/console.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp
index 367e7e87..dc2e1a25 100644
--- a/src/engine/shared/console.cpp
+++ b/src/engine/shared/console.cpp
@@ -157,11 +157,15 @@ void CConsole::RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUse
 	m_pPrintCallbackUserdata = pUserData;
 }
 
-void CConsole::Print(const char *pStr)
+void CConsole::Print(int Level, const char *pFrom, const char *pStr)
 {
-	dbg_msg("console" ,"%s", pStr);
-	if (m_pfnPrintCallback)
-		m_pfnPrintCallback(pStr, m_pPrintCallbackUserdata);
+	dbg_msg(pFrom ,"%s", pStr);
+	if (Level <= g_Config.m_ConsoleOutputLevel && m_pfnPrintCallback)
+	{
+		char aBuf[1024];
+		str_format(aBuf, sizeof(aBuf), "[%s]: %s", pFrom, pStr);
+		m_pfnPrintCallback(aBuf, m_pPrintCallbackUserdata);
+	}
 }
 
 void CConsole::ExecuteLineStroked(int Stroke, const char *pStr)
@@ -218,7 +222,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr)
 				{
 					char aBuf[256];
 					str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams);
-					Print(aBuf);
+					Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
 				}
 				else if(m_StoreCommands && pCommand->m_Flags&CFGFLAG_STORE)
 				{
@@ -234,7 +238,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr)
 		{
 			char aBuf[256];
 			str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand);
-			Print(aBuf);
+			Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf);
 		}
 		
 		pStr = pNextPart;
@@ -298,12 +302,14 @@ void CConsole::ExecuteFile(const char *pFilename)
 	// exec the file
 	IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_READ);
 	
+	char aBuf[256];
 	if(File)
 	{
 		char *pLine;
 		CLineReader lr;
 		
-		dbg_msg("console", "executing '%s'", pFilename);
+		str_format(aBuf, sizeof(aBuf), "executing '%s'", pFilename);
+		Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
 		lr.Init(File);
 
 		while((pLine = lr.Get()))
@@ -312,14 +318,17 @@ void CConsole::ExecuteFile(const char *pFilename)
 		io_close(File);
 	}
 	else
-		dbg_msg("console", "failed to open '%s'", pFilename);
+	{
+		str_format(aBuf, sizeof(aBuf), "failed to open '%s'", pFilename);
+		Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf);
+	}
 	
 	m_pFirstExec = pPrev;
 }
 
 void CConsole::Con_Echo(IResult *pResult, void *pUserData)
 {
-	((CConsole*)pUserData)->Print(pResult->GetString(0));
+	((CConsole*)pUserData)->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", pResult->GetString(0));
 }
 
 void CConsole::Con_Exec(IResult *pResult, void *pUserData)
@@ -365,7 +374,7 @@ static void IntVariableCommand(IConsole::IResult *pResult, void *pUserData)
 	{
 		char aBuf[1024];
 		str_format(aBuf, sizeof(aBuf), "Value: %d", *(pData->m_pVariable));
-		pData->m_pConsole->Print(aBuf);
+		pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf);
 	}
 }
 
@@ -379,7 +388,7 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData)
 	{
 		char aBuf[1024];
 		str_format(aBuf, sizeof(aBuf), "Value: %s", pData->m_pStr);
-		pData->m_pConsole->Print(aBuf);
+		pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Console", aBuf);
 	}
 }
 
@@ -466,7 +475,9 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void
 	
 	if(!pCommand)
 	{
-		dbg_msg("console", "failed to chain '%s'", pName);
+		char aBuf[256];
+		str_format(aBuf, sizeof(aBuf), "failed to chain '%s'", pName);
+		Print(IConsole::OUTPUT_LEVEL_DEBUG, "console", aBuf);
 		return;
 	}