@@ -1217,10 +1217,38 @@ where
1217
1217
///
1218
1218
/// Note that `Trace` is the maximum level, because it provides the maximum amount of detail in the emitted logs.
1219
1219
#[ inline]
1220
+ #[ cfg( atomic_cas) ]
1220
1221
pub fn set_max_level ( level : LevelFilter ) {
1221
1222
MAX_LOG_LEVEL_FILTER . store ( level as usize , Ordering :: Relaxed ) ;
1222
1223
}
1223
1224
1225
+ /// A thread-unsafe version of [`set_max_level`].
1226
+ ///
1227
+ /// This function is available on all platforms, even those that do not have
1228
+ /// support for atomics that is needed by [`set_max_level`].
1229
+ ///
1230
+ /// In almost all cases, [`set_max_level`] should be preferred.
1231
+ ///
1232
+ /// # Safety
1233
+ ///
1234
+ /// This function is only safe to call when no other level setting function is
1235
+ /// called while this function still executes.
1236
+ ///
1237
+ /// This can be upheld by (for example) making sure that **there are no other
1238
+ /// threads**, and (on embedded) that **interrupts are disabled**.
1239
+ ///
1240
+ /// Is is safe to use all other logging functions while this function runs
1241
+ /// (including all logging macros).
1242
+ ///
1243
+ /// [`set_max_level`]: fn.set_max_level.html
1244
+ #[ inline]
1245
+ pub unsafe fn set_max_level_racy ( level : LevelFilter ) {
1246
+ // `MAX_LOG_LEVEL_FILTER` uses a `Cell` as the underlying primitive when a
1247
+ // platform doesn't support `atomic_cas`, so even though this looks the same
1248
+ // as `set_max_level` it may have different safety properties.
1249
+ MAX_LOG_LEVEL_FILTER . store ( level as usize , Ordering :: Relaxed ) ;
1250
+ }
1251
+
1224
1252
/// Returns the current maximum log level.
1225
1253
///
1226
1254
/// The [`log!`], [`error!`], [`warn!`], [`info!`], [`debug!`], and [`trace!`] macros check
0 commit comments