10using System.Reflection;
13 public static class Logger {
18 public static void Log(
object message) {
22 public static void LogStruct(
object thisObject,
string title =
"") {
24 if (!thisObject.GetType().IsValueType) {
25 Log(title +
" ---- Trying to log non-struct with struct logger");
28 Log(title +
" ---- " + thisObject.GetType().ToString());
29 FieldInfo[] fieldInfos;
30 fieldInfos = thisObject.GetType().GetFields(
31 BindingFlags.Public | BindingFlags.NonPublic
32 | BindingFlags.Static | BindingFlags.Instance
33 | BindingFlags.FlattenHierarchy);
36 foreach (FieldInfo fieldInfo
in fieldInfos) {
37 object obj = fieldInfo.GetValue(thisObject);
38 string value = obj ==
null ?
"null" : obj.ToString();
39 Log(
" -------- Name: " + fieldInfo.Name +
", Value = " + value);
41 }
catch (Exception exception) {
42 Log(exception.Message);