@@ -22,13 +22,15 @@ public static class MetadataProvidersGuard
2222 private static MethodInfo instanceCanRefresh ;
2323 private static ILogger logger ;
2424 private static bool isEnabled ;
25+ private static bool logEnabled ;
2526
26- public static void Initialize ( ILogger pluginLogger , bool disableSystemMetadata )
27+ public static void Initialize ( ILogger pluginLogger , bool disableSystemMetadata , bool enableLog )
2728 {
2829 if ( harmony != null ) return ;
2930
3031 logger = pluginLogger ;
3132 isEnabled = disableSystemMetadata ;
33+ logEnabled = enableLog ;
3234
3335 try
3436 {
@@ -89,10 +91,14 @@ public static void Initialize(ILogger pluginLogger, bool disableSystemMetadata)
8991 }
9092 }
9193
92- public static void Configure ( bool disableSystemMetadata )
94+ public static void Configure ( bool disableSystemMetadata , bool enableLog )
9395 {
9496 isEnabled = disableSystemMetadata ;
95- logger ? . Info ( "MetadataProvidersGuard " + ( isEnabled ? "enabled" : "disabled" ) ) ;
97+ logEnabled = enableLog ;
98+ if ( logEnabled )
99+ {
100+ logger ? . Info ( "MetadataProvidersGuard " + ( isEnabled ? "enabled" : "disabled" ) ) ;
101+ }
96102 }
97103
98104 public static IDisposable Allow ( )
@@ -111,11 +117,17 @@ private static bool CanRefreshPrefix(ref bool __result)
111117 if ( GuardCount . Value == 0 )
112118 {
113119 __result = false ;
114- logger ? . Info ( $ "MetadataProvidersGuard 拦截 CanRefresh") ;
120+ if ( logEnabled )
121+ {
122+ logger ? . Info ( $ "MetadataProvidersGuard 拦截 CanRefresh") ;
123+ }
115124 return false ;
116125 }
117126
118- logger ? . Info ( $ "MetadataProvidersGuard 放行 CanRefresh") ;
127+ if ( logEnabled )
128+ {
129+ logger ? . Info ( $ "MetadataProvidersGuard 放行 CanRefresh") ;
130+ }
119131 return true ;
120132 }
121133
0 commit comments