/// <summary> /// Logs a message to the console. /// </summary> /// <param name="style"> A style which influences the icon and text color. </param> /// <param name="objects"> The objects to output to the console. These can be strings or /// ObjectInstances. </param> public void Log(consoleMessageStyle style, object[] objects) { // Convert the objects to a string. var message = new System.Text.StringBuilder(); for (int i = 0; i < objects.Length; i++) { if (i != 0) { message.Append(' '); } message.Append(objects[i].ToString()); } // Output the message to the console. UnityEngine.Debug.Log(message.ToString()); }
/// <summary> /// Logs a message to the console. /// </summary> /// <param name="style"> A style which influences the icon and text color. </param> /// <param name="objects"> The objects to output to the console. These can be strings or /// ObjectInstances. </param> public void Log(consoleMessageStyle style, object[] objects) { #if !SILVERLIGHT var original = Console.ForegroundColor; switch (style) { case consoleMessageStyle.Information: Console.ForegroundColor = ConsoleColor.White; break; case consoleMessageStyle.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case consoleMessageStyle.Error: Console.ForegroundColor = ConsoleColor.Red; break; } #endif // Convert the objects to a string. var message = new System.Text.StringBuilder(); for (int i = 0; i < objects.Length; i++) { if (i != 0) { message.Append(' '); } message.Append(TypeConverter.ToString(objects[i])); } // Output the message to the console. Wrench.Log.Add(message.ToString()); #if !SILVERLIGHT if (style != consoleMessageStyle.Regular) { Console.ForegroundColor = original; } #endif }
// PRIVATE METHODS //_________________________________________________________________________________________ /// <summary> /// Logs a message to the console. The objects provided will be converted to strings then /// joined together in a space separated line. The first parameter can be a string /// containing the following patterns: /// %s String /// %d, %i Integer /// %f Floating point number /// </summary> /// <param name="style"> The style of the message (this determines the icon and text /// color). </param> /// <param name="items"> The items to format. </param> private void log(consoleMessageStyle style, params object[] items) { this.output.Log(style, FormatObjects(items)); }