From 16a4c315a2468bd6ebfd947fe936769557143ee1 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Sun, 2 Dec 2018 11:05:21 -0500 Subject: [PATCH 1/3] PR comments --- CMakeLists.txt | 1 - src/client/spark/Spark.csproj | 5 --- .../Properties/AssemblyAttributes.cs | 1 - src/client/spark_api/utils/Log.cs | 33 +++++++++++++++++-- src/client/spark_sdk/samples/SDKMain.cs | 2 +- src/client/spark_sdk/spark_sdk.csproj | 5 --- src/lib/CMakeLists.txt | 6 ---- src/lib/logging/logging.h | 3 +- 8 files changed, 34 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c02bd56e1..b497a3092 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,6 @@ else () add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/server COMMAND mkdir -p ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/sparkd ${CMAKE_BINARY_DIR}/server - #COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/defaults ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server diff --git a/src/client/spark/Spark.csproj b/src/client/spark/Spark.csproj index f919ead4c..f3579dcd9 100644 --- a/src/client/spark/Spark.csproj +++ b/src/client/spark/Spark.csproj @@ -82,9 +82,4 @@ - - - - - diff --git a/src/client/spark_api/Properties/AssemblyAttributes.cs b/src/client/spark_api/Properties/AssemblyAttributes.cs index dbfda4671..74885c3bb 100644 --- a/src/client/spark_api/Properties/AssemblyAttributes.cs +++ b/src/client/spark_api/Properties/AssemblyAttributes.cs @@ -3,5 +3,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("spark_core")] [assembly: InternalsVisibleTo("sparkcmd")] [assembly: InternalsVisibleTo("spark_test")] -[assembly: InternalsVisibleTo("spark_sdk")] diff --git a/src/client/spark_api/utils/Log.cs b/src/client/spark_api/utils/Log.cs index d07b338ca..f9477ad11 100644 --- a/src/client/spark_api/utils/Log.cs +++ b/src/client/spark_api/utils/Log.cs @@ -32,10 +32,12 @@ namespace bts { Testing, Latency, DataFlow, - Plugin + Plugin, + Sdk // Please keep this list in sync with logging.h/logging.cpp } - readonly struct Logger { + + readonly struct Logger : ILogger { readonly Subsystem _sys; public Logger(Subsystem sys) { _sys = sys; @@ -74,6 +76,7 @@ namespace bts { public static Logger Ui => new Logger(Subsystem.Ui); public static Logger Testing => new Logger(Subsystem.Testing); public static Logger DataFlow => new Logger(Subsystem.DataFlow); + public static Logger Sdk => new Logger(Subsystem.DataFlow); [Conditional("DEBUG")] @@ -105,4 +108,30 @@ namespace bts { public static event Action OnSystemCrashing; } + + public interface ILogger + { + void diag(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); + void info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); + void warn(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); + void error(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); + void fatal(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); + } + namespace sdk + { + public static class Log + { + public static ILogger logger => new Logger(Subsystem.Sdk); + [Conditional("DEBUG")] + public static void assert_d(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) + { + bts.Log.assert(test, message, file, line); + } + + public static void assert(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) + { + bts.Log.assert(test, message, file, line); + } + } + } } diff --git a/src/client/spark_sdk/samples/SDKMain.cs b/src/client/spark_sdk/samples/SDKMain.cs index 0df8bf030..0131720cf 100644 --- a/src/client/spark_sdk/samples/SDKMain.cs +++ b/src/client/spark_sdk/samples/SDKMain.cs @@ -24,7 +24,7 @@ namespace bts.sdk } public static void Main(string[] args) { - bts.Log.Gen.info("Welcome to the BTS Client Side SDK example"); + Log.logger.info("Welcome to the BTS Client Side SDK example"); if (args.FirstOrDefault() == "users") { user_test(); diff --git a/src/client/spark_sdk/spark_sdk.csproj b/src/client/spark_sdk/spark_sdk.csproj index e2165daf3..2fd523f62 100644 --- a/src/client/spark_sdk/spark_sdk.csproj +++ b/src/client/spark_sdk/spark_sdk.csproj @@ -57,7 +57,6 @@ - @@ -88,13 +87,9 @@ - - <_Defaults Include="..\..\defaults\*.*" /> - - diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 7a2b5d472..2bc9cd150 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -76,12 +76,6 @@ if(NOT config_defaults_str STREQUAL old_defaults_str) endif() -# copy defaults to output directory -#foreach (cfg_file_path ${Conf_Defaults}) -# get_filename_component(cfg_file_name ${cfg_file_path} NAME) -# configure_file(${cfg_file_path} ${CMAKE_BINARY_DIR}/src/server/sparkd/defaults/${cfg_file_name}) -#endforeach(cfg_file_path) - # lib if (WIN32) add_library(libspark SHARED diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index dc4e2281f..a9f59017d 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -42,7 +42,8 @@ constexpr log::Subsystem Mercury {ExSim.ordinal+1 }; constexpr log::Subsystem Testing {Mercury.ordinal+1 }; constexpr log::Subsystem Latency {Testing.ordinal+1 }; constexpr log::Subsystem DataFlow {Latency.ordinal+1 }; -constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; +constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; +constexpr log::Subsystem Sdk {Plugin.ordinal+1 }; struct LoggerHandle { LoggerHandle(LoggerHandle const&) = delete; From 4987fc9fc17a85a16e4140b9e43b38b16209b319 Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Sun, 2 Dec 2018 21:20:00 -0500 Subject: [PATCH 2/3] this? --- src/client/spark_api/utils/Log.cs | 66 ++++++++----------------- src/client/spark_sdk/samples/SDKMain.cs | 2 +- src/lib/logging/logging.h | 2 +- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/src/client/spark_api/utils/Log.cs b/src/client/spark_api/utils/Log.cs index f9477ad11..1788701ec 100644 --- a/src/client/spark_api/utils/Log.cs +++ b/src/client/spark_api/utils/Log.cs @@ -13,7 +13,7 @@ namespace bts { Sys } - enum Subsystem { + public enum Subsystem { gen, Config, QBus, @@ -33,11 +33,11 @@ namespace bts { Latency, DataFlow, Plugin, - Sdk + ClientSdk // Please keep this list in sync with logging.h/logging.cpp } - readonly struct Logger : ILogger { + public readonly struct Logger { readonly Subsystem _sys; public Logger(Subsystem sys) { _sys = sys; @@ -63,20 +63,20 @@ namespace bts { static extern void Logger_log (Level level, Subsystem subsystem, string message, string file, int line); } - static class Log { - public static Logger Gen => new Logger(Subsystem.gen); - public static Logger Config => new Logger(Subsystem.Config); - public static Logger QBus => new Logger(Subsystem.QBus); - public static Logger Md => new Logger(Subsystem.md); - public static Logger Api => new Logger(Subsystem.Api); - public static Logger Persist => new Logger(Subsystem.Persist); - public static Logger User => new Logger(Subsystem.User); - public static Logger OrderMan => new Logger(Subsystem.OrderMan); - public static Logger Assert => new Logger(Subsystem.Assert); - public static Logger Ui => new Logger(Subsystem.Ui); - public static Logger Testing => new Logger(Subsystem.Testing); - public static Logger DataFlow => new Logger(Subsystem.DataFlow); - public static Logger Sdk => new Logger(Subsystem.DataFlow); + public static class Log { + internal static Logger Gen => new Logger(Subsystem.gen); + internal static Logger Config => new Logger(Subsystem.Config); + internal static Logger QBus => new Logger(Subsystem.QBus); + internal static Logger Md => new Logger(Subsystem.md); + internal static Logger Api => new Logger(Subsystem.Api); + internal static Logger Persist => new Logger(Subsystem.Persist); + internal static Logger User => new Logger(Subsystem.User); + internal static Logger OrderMan => new Logger(Subsystem.OrderMan); + internal static Logger Assert => new Logger(Subsystem.Assert); + internal static Logger Ui => new Logger(Subsystem.Ui); + internal static Logger Testing => new Logger(Subsystem.Testing); + internal static Logger DataFlow => new Logger(Subsystem.DataFlow); + public static Logger ClientSdk => new Logger(Subsystem.ClientSdk); [Conditional("DEBUG")] @@ -102,36 +102,10 @@ namespace bts { assert(o == null); } delegate void on_crash_callback([MarshalAs(UnmanagedType.LPStr)]string msg, [MarshalAs(UnmanagedType.LPStr)] string details); - public static void system_is_crashing(string message, object details) { + internal static void system_is_crashing(string message, object details) { OnSystemCrashing?.Invoke(message, details); } - public static event Action OnSystemCrashing; + internal static event Action OnSystemCrashing; - } - - public interface ILogger - { - void diag(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); - void info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); - void warn(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); - void error(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); - void fatal(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0); - } - namespace sdk - { - public static class Log - { - public static ILogger logger => new Logger(Subsystem.Sdk); - [Conditional("DEBUG")] - public static void assert_d(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) - { - bts.Log.assert(test, message, file, line); - } - - public static void assert(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) - { - bts.Log.assert(test, message, file, line); - } - } - } + } } diff --git a/src/client/spark_sdk/samples/SDKMain.cs b/src/client/spark_sdk/samples/SDKMain.cs index 0131720cf..5a9f5452d 100644 --- a/src/client/spark_sdk/samples/SDKMain.cs +++ b/src/client/spark_sdk/samples/SDKMain.cs @@ -24,7 +24,7 @@ namespace bts.sdk } public static void Main(string[] args) { - Log.logger.info("Welcome to the BTS Client Side SDK example"); + Log.ClientSdk.info("Welcome to the BTS Client Side SDK example"); if (args.FirstOrDefault() == "users") { user_test(); diff --git a/src/lib/logging/logging.h b/src/lib/logging/logging.h index a9f59017d..919234a6e 100644 --- a/src/lib/logging/logging.h +++ b/src/lib/logging/logging.h @@ -43,7 +43,7 @@ constexpr log::Subsystem Testing {Mercury.ordinal+1 }; constexpr log::Subsystem Latency {Testing.ordinal+1 }; constexpr log::Subsystem DataFlow {Latency.ordinal+1 }; constexpr log::Subsystem Plugin {DataFlow.ordinal+1 }; -constexpr log::Subsystem Sdk {Plugin.ordinal+1 }; +constexpr log::Subsystem ClientSdk {Plugin.ordinal+1 }; struct LoggerHandle { LoggerHandle(LoggerHandle const&) = delete; From 71c66f127d039486a66c0a1187dcb3d5a369b313 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Mon, 3 Dec 2018 08:46:53 -0500 Subject: [PATCH 3/3] What about this? --- src/client/spark_api/utils/Log.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/spark_api/utils/Log.cs b/src/client/spark_api/utils/Log.cs index 1788701ec..f6eb912e1 100644 --- a/src/client/spark_api/utils/Log.cs +++ b/src/client/spark_api/utils/Log.cs @@ -13,7 +13,7 @@ namespace bts { Sys } - public enum Subsystem { + enum Subsystem { gen, Config, QBus, @@ -39,7 +39,7 @@ namespace bts { public readonly struct Logger { readonly Subsystem _sys; - public Logger(Subsystem sys) { + internal Logger(Subsystem sys) { _sys = sys; }