Description:
Tweak Spy method.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r238:d02e9c30104d -

@@ -104,7 +104,7
104 104 var start_y = random_generator.Next(0, 50);
105 105
106 106 Logging.Spy(start_x, nameof(start_x));
107 Logging.Spy(new {start_x});
107 Logging.Spy(new {start_x, start_y});
108 108
109 109 int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares;
110 110 int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares;
@@ -2,6 +2,8
2 2 using System;
3 3 using System.Collections.Generic;
4 4 using System.Runtime.CompilerServices;
5 using System.Reflection;
6 // using System.Linq;
5 7
6 8 /* Tiny log library inspired by Python's logging and Glögi.
7 9 */
@@ -154,8 +156,20
154 156
155 157 ) where T : class
156 158 {
157 string message = string.Format("{0} = {1}",
158 value.ToString(), typeof(T).GetProperties()[0].ToString() );
159 // var properties = typeof(T).GetProperties();
160 // string message = string.Format("{0} = {1}",
161 // value.ToString(), .ToString() );
162 // var message = String.Join(", ", (object[])properties);
163
164 var properties = new List<string>();
165
166 foreach (var property in typeof(T).GetProperties())
167 {
168 properties.Add(property.ToString() + "=" + property.GetValue(value));
169 }
170
171 var message = "{" + String.Join(", ", properties) + "}";
172
159 173 Logging.Log_(LogLevel.Spy, message, lineNumber, caller, path);
160 174 }
161 175 }
You need to be logged in to leave comments. Login now