From 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 Mon Sep 17 00:00:00 2001
From:
Date: Mon, 29 Jun 2015 20:16:15 +0000
Subject: Update documentation
---
src/log/lib.rs.html | 1643 ++++++++++++++++++++++++++++++++++++++++++++++++
src/log/macros.rs.html | 387 ++++++++++++
2 files changed, 2030 insertions(+)
create mode 100644 src/log/lib.rs.html
create mode 100644 src/log/macros.rs.html
(limited to 'src/log')
diff --git a/src/log/lib.rs.html b/src/log/lib.rs.html
new file mode 100644
index 0000000..78cbf86
--- /dev/null
+++ b/src/log/lib.rs.html
@@ -0,0 +1,1643 @@
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+ html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+ html_root_url = "http://doc.rust-lang.org/log/")]
+#![warn(missing_docs)]
+
+extern crate libc;
+
+use std::ascii::AsciiExt;
+use std::cmp;
+use std::error;
+use std::fmt;
+use std::mem;
+use std::ops::Deref;
+use std::str::FromStr;
+use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
+mod macros;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+static LOGGER: AtomicUsize = ATOMIC_USIZE_INIT;
+static REFCOUNT: AtomicUsize = ATOMIC_USIZE_INIT;
+
+const UNINITIALIZED: usize = 0;
+const INITIALIZING: usize = 1;
+
+static MAX_LOG_LEVEL_FILTER: AtomicUsize = ATOMIC_USIZE_INIT;
+
+static LOG_LEVEL_NAMES: [&'static str; 6] = ["OFF", "ERROR", "WARN", "INFO",
+ "DEBUG", "TRACE"];
+
+
+
+
+#[repr(usize)]
+#[derive(Copy, Eq, Debug)]
+pub enum LogLevel {
+
+
+
+ Error = 1,
+
+
+
+ Warn,
+
+
+
+ Info,
+
+
+
+ Debug,
+
+
+
+ Trace,
+}
+
+impl Clone for LogLevel {
+ #[inline]
+ fn clone(&self) -> LogLevel {
+ *self
+ }
+}
+
+impl PartialEq for LogLevel {
+ #[inline]
+ fn eq(&self, other: &LogLevel) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialEq<LogLevelFilter> for LogLevel {
+ #[inline]
+ fn eq(&self, other: &LogLevelFilter) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialOrd for LogLevel {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl PartialOrd<LogLevelFilter> for LogLevel {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
+ Some((*self as usize).cmp(&(*other as usize)))
+ }
+}
+
+impl Ord for LogLevel {
+ #[inline]
+ fn cmp(&self, other: &LogLevel) -> cmp::Ordering {
+ (*self as usize).cmp(&(*other as usize))
+ }
+}
+
+fn ok_or<T, E>(t: Option<T>, e: E) -> Result<T, E> {
+ match t {
+ Some(t) => Ok(t),
+ None => Err(e),
+ }
+}
+
+impl FromStr for LogLevel {
+ type Err = ();
+ fn from_str(level: &str) -> Result<LogLevel, ()> {
+ ok_or(LOG_LEVEL_NAMES.iter()
+ .position(|&name| name.eq_ignore_ascii_case(level))
+ .into_iter()
+ .filter(|&idx| idx != 0)
+ .map(|idx| LogLevel::from_usize(idx).unwrap())
+ .next(), ())
+ }
+}
+
+impl fmt::Display for LogLevel {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ fmt.pad(LOG_LEVEL_NAMES[*self as usize])
+ }
+}
+
+impl LogLevel {
+ fn from_usize(u: usize) -> Option<LogLevel> {
+ match u {
+ 1 => Some(LogLevel::Error),
+ 2 => Some(LogLevel::Warn),
+ 3 => Some(LogLevel::Info),
+ 4 => Some(LogLevel::Debug),
+ 5 => Some(LogLevel::Trace),
+ _ => None
+ }
+ }
+
+
+ #[inline]
+ pub fn max() -> LogLevel {
+ LogLevel::Trace
+ }
+
+
+ #[inline]
+ pub fn to_log_level_filter(&self) -> LogLevelFilter {
+ LogLevelFilter::from_usize(*self as usize).unwrap()
+ }
+}
+
+
+
+
+
+#[repr(usize)]
+#[derive(Copy, Eq, Debug)]
+pub enum LogLevelFilter {
+
+ Off,
+
+ Error,
+
+ Warn,
+
+ Info,
+
+ Debug,
+
+ Trace,
+}
+
+
+
+impl Clone for LogLevelFilter {
+ #[inline]
+ fn clone(&self) -> LogLevelFilter {
+ *self
+ }
+}
+
+impl PartialEq for LogLevelFilter {
+ #[inline]
+ fn eq(&self, other: &LogLevelFilter) -> bool {
+ *self as usize == *other as usize
+ }
+}
+
+impl PartialEq<LogLevel> for LogLevelFilter {
+ #[inline]
+ fn eq(&self, other: &LogLevel) -> bool {
+ other.eq(self)
+ }
+}
+
+impl PartialOrd for LogLevelFilter {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevelFilter) -> Option<cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl PartialOrd<LogLevel> for LogLevelFilter {
+ #[inline]
+ fn partial_cmp(&self, other: &LogLevel) -> Option<cmp::Ordering> {
+ other.partial_cmp(self).map(|x| x.reverse())
+ }
+}
+
+impl Ord for LogLevelFilter {
+ #[inline]
+ fn cmp(&self, other: &LogLevelFilter) -> cmp::Ordering {
+ (*self as usize).cmp(&(*other as usize))
+ }
+}
+
+impl FromStr for LogLevelFilter {
+ type Err = ();
+ fn from_str(level: &str) -> Result<LogLevelFilter, ()> {
+ ok_or(LOG_LEVEL_NAMES.iter()
+ .position(|&name| name.eq_ignore_ascii_case(level))
+ .map(|p| LogLevelFilter::from_usize(p).unwrap()), ())
+ }
+}
+
+impl fmt::Display for LogLevelFilter {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "{}", LOG_LEVEL_NAMES[*self as usize])
+ }
+}
+
+impl LogLevelFilter {
+ fn from_usize(u: usize) -> Option<LogLevelFilter> {
+ match u {
+ 0 => Some(LogLevelFilter::Off),
+ 1 => Some(LogLevelFilter::Error),
+ 2 => Some(LogLevelFilter::Warn),
+ 3 => Some(LogLevelFilter::Info),
+ 4 => Some(LogLevelFilter::Debug),
+ 5 => Some(LogLevelFilter::Trace),
+ _ => None
+ }
+ }
+
+ #[inline]
+ pub fn max() -> LogLevelFilter {
+ LogLevelFilter::Trace
+ }
+
+
+
+
+ #[inline]
+ pub fn to_log_level(&self) -> Option<LogLevel> {
+ LogLevel::from_usize(*self as usize)
+ }
+}
+
+
+pub struct LogRecord<'a> {
+ metadata: LogMetadata<'a>,
+ location: &'a LogLocation,
+ args: fmt::Arguments<'a>,
+}
+
+impl<'a> LogRecord<'a> {
+
+ pub fn args(&self) -> &fmt::Arguments<'a> {
+ &self.args
+ }
+
+
+ pub fn metadata(&self) -> &LogMetadata {
+ &self.metadata
+ }
+
+
+ pub fn location(&self) -> &LogLocation {
+ self.location
+ }
+
+
+ pub fn level(&self) -> LogLevel {
+ self.metadata.level()
+ }
+
+
+ pub fn target(&self) -> &str {
+ self.metadata.target()
+ }
+}
+
+
+pub struct LogMetadata<'a> {
+ level: LogLevel,
+ target: &'a str,
+}
+
+impl<'a> LogMetadata<'a> {
+
+ pub fn level(&self) -> LogLevel {
+ self.level
+ }
+
+
+ pub fn target(&self) -> &str {
+ self.target
+ }
+}
+
+
+pub trait Log: Sync+Send {
+
+
+
+
+
+
+ fn enabled(&self, metadata: &LogMetadata) -> bool;
+
+
+
+
+
+
+ fn log(&self, record: &LogRecord);
+}
+
+
+
+
+
+
+
+
+#[derive(Copy, Clone, Debug)]
+pub struct LogLocation {
+ #[doc(hidden)]
+ pub __module_path: &'static str,
+ #[doc(hidden)]
+ pub __file: &'static str,
+ #[doc(hidden)]
+ pub __line: u32,
+}
+
+impl LogLocation {
+
+ pub fn module_path(&self) -> &str {
+ self.__module_path
+ }
+
+
+ pub fn file(&self) -> &str {
+ self.__file
+ }
+
+
+ pub fn line(&self) -> u32 {
+ self.__line
+ }
+}
+
+
+
+
+
+
+
+
+
+#[allow(missing_copy_implementations)]
+pub struct MaxLogLevelFilter(());
+
+impl fmt::Debug for MaxLogLevelFilter {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "MaxLogLevelFilter")
+ }
+}
+
+impl MaxLogLevelFilter {
+
+ pub fn get(&self) -> LogLevelFilter {
+ max_log_level()
+ }
+
+
+ pub fn set(&self, level: LogLevelFilter) {
+ MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst)
+ }
+}
+
+
+
+
+
+
+#[inline(always)]
+pub fn max_log_level() -> LogLevelFilter {
+ unsafe { mem::transmute(MAX_LOG_LEVEL_FILTER.load(Ordering::Relaxed)) }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+pub fn set_logger<M>(make_logger: M) -> Result<(), SetLoggerError>
+ where M: FnOnce(MaxLogLevelFilter) -> Box<Log> {
+ if LOGGER.compare_and_swap(UNINITIALIZED, INITIALIZING,
+ Ordering::SeqCst) != UNINITIALIZED {
+ return Err(SetLoggerError(()));
+ }
+
+ let logger = Box::new(make_logger(MaxLogLevelFilter(())));
+ let logger = unsafe { mem::transmute::<Box<Box<Log>>, usize>(logger) };
+ LOGGER.store(logger, Ordering::SeqCst);
+
+ unsafe {
+ assert_eq!(libc::atexit(shutdown), 0);
+ }
+ return Ok(());
+
+ extern fn shutdown() {
+
+ let logger = LOGGER.swap(INITIALIZING, Ordering::SeqCst);
+
+ while REFCOUNT.load(Ordering::SeqCst) != 0 {
+
+ }
+
+ unsafe { mem::transmute::<usize, Box<Box<Log>>>(logger); }
+ }
+}
+
+
+#[allow(missing_copy_implementations)]
+#[derive(Debug)]
+pub struct SetLoggerError(());
+
+impl fmt::Display for SetLoggerError {
+ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+ write!(fmt, "attempted to set a logger after the logging system \
+ was already initialized")
+ }
+}
+
+impl error::Error for SetLoggerError {
+ fn description(&self) -> &str { "set_logger() called multiple times" }
+}
+
+struct LoggerGuard(usize);
+
+impl Drop for LoggerGuard {
+ fn drop(&mut self) {
+ REFCOUNT.fetch_sub(1, Ordering::SeqCst);
+ }
+}
+
+impl Deref for LoggerGuard {
+ type Target = Box<Log>;
+
+ fn deref(&self) -> &Box<Log+'static> {
+ unsafe { mem::transmute(self.0) }
+ }
+}
+
+fn logger() -> Option<LoggerGuard> {
+ REFCOUNT.fetch_add(1, Ordering::SeqCst);
+ let logger = LOGGER.load(Ordering::SeqCst);
+ if logger == UNINITIALIZED || logger == INITIALIZING {
+ REFCOUNT.fetch_sub(1, Ordering::SeqCst);
+ None
+ } else {
+ Some(LoggerGuard(logger))
+ }
+}
+
+
+
+
+#[doc(hidden)]
+pub fn __enabled(level: LogLevel, target: &str) -> bool {
+ if let Some(logger) = logger() {
+ logger.enabled(&LogMetadata { level: level, target: target })
+ } else {
+ false
+ }
+}
+
+
+
+
+#[doc(hidden)]
+pub fn __log(level: LogLevel, target: &str, loc: &LogLocation,
+ args: fmt::Arguments) {
+ if let Some(logger) = logger() {
+ let record = LogRecord {
+ metadata: LogMetadata {
+ level: level,
+ target: target,
+ },
+ location: loc,
+ args: args
+ };
+ logger.log(&record)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use std::error::Error;
+ use super::{LogLevel, LogLevelFilter, SetLoggerError};
+
+ #[test]
+ fn test_loglevelfilter_from_str() {
+ let tests = [
+ ("off", Ok(LogLevelFilter::Off)),
+ ("error", Ok(LogLevelFilter::Error)),
+ ("warn", Ok(LogLevelFilter::Warn)),
+ ("info", Ok(LogLevelFilter::Info)),
+ ("debug", Ok(LogLevelFilter::Debug)),
+ ("trace", Ok(LogLevelFilter::Trace)),
+ ("OFF", Ok(LogLevelFilter::Off)),
+ ("ERROR", Ok(LogLevelFilter::Error)),
+ ("WARN", Ok(LogLevelFilter::Warn)),
+ ("INFO", Ok(LogLevelFilter::Info)),
+ ("DEBUG", Ok(LogLevelFilter::Debug)),
+ ("TRACE", Ok(LogLevelFilter::Trace)),
+ ("asdf", Err(())),
+ ];
+ for &(s, ref expected) in &tests {
+ assert_eq!(expected, &s.parse());
+ }
+ }
+
+ #[test]
+ fn test_loglevel_from_str() {
+ let tests = [
+ ("OFF", Err(())),
+ ("error", Ok(LogLevel::Error)),
+ ("warn", Ok(LogLevel::Warn)),
+ ("info", Ok(LogLevel::Info)),
+ ("debug", Ok(LogLevel::Debug)),
+ ("trace", Ok(LogLevel::Trace)),
+ ("ERROR", Ok(LogLevel::Error)),
+ ("WARN", Ok(LogLevel::Warn)),
+ ("INFO", Ok(LogLevel::Info)),
+ ("DEBUG", Ok(LogLevel::Debug)),
+ ("TRACE", Ok(LogLevel::Trace)),
+ ("asdf", Err(())),
+ ];
+ for &(s, ref expected) in &tests {
+ assert_eq!(expected, &s.parse());
+ }
+ }
+
+ #[test]
+ fn test_loglevel_show() {
+ assert_eq!("INFO", LogLevel::Info.to_string());
+ assert_eq!("ERROR", LogLevel::Error.to_string());
+ }
+
+ #[test]
+ fn test_loglevelfilter_show() {
+ assert_eq!("OFF", LogLevelFilter::Off.to_string());
+ assert_eq!("ERROR", LogLevelFilter::Error.to_string());
+ }
+
+ #[test]
+ fn test_cross_cmp() {
+ assert!(LogLevel::Debug > LogLevelFilter::Error);
+ assert!(LogLevelFilter::Warn < LogLevel::Trace);
+ assert!(LogLevelFilter::Off < LogLevel::Error);
+ }
+
+ #[test]
+ fn test_cross_eq() {
+ assert!(LogLevel::Error == LogLevelFilter::Error);
+ assert!(LogLevelFilter::Off != LogLevel::Error);
+ assert!(LogLevel::Trace == LogLevelFilter::Trace);
+ }
+
+ #[test]
+ fn test_to_log_level() {
+ assert_eq!(Some(LogLevel::Error), LogLevelFilter::Error.to_log_level());
+ assert_eq!(None, LogLevelFilter::Off.to_log_level());
+ assert_eq!(Some(LogLevel::Debug), LogLevelFilter::Debug.to_log_level());
+ }
+
+ #[test]
+ fn test_to_log_level_filter() {
+ assert_eq!(LogLevelFilter::Error, LogLevel::Error.to_log_level_filter());
+ assert_eq!(LogLevelFilter::Trace, LogLevel::Trace.to_log_level_filter());
+ }
+
+ #[test]
+ fn test_error_trait() {
+ let e = SetLoggerError(());
+ assert_eq!(e.description(), "set_logger() called multiple times");
+ }
+}
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#[macro_export]
+macro_rules! log {
+ (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({
+ static LOC: $crate::LogLocation = $crate::LogLocation {
+ __line: line!(),
+ __file: file!(),
+ __module_path: module_path!(),
+ };
+ let lvl = $lvl;
+ if !cfg!(log_level = "off") &&
+ (lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) &&
+ (lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) &&
+ (lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) &&
+ (lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) &&
+ lvl <= $crate::max_log_level() {
+ $crate::__log(lvl, $target, &LOC, format_args!($($arg)+))
+ }
+ });
+ ($lvl:expr, $($arg:tt)+) => (log!(target: module_path!(), $lvl, $($arg)+))
+}
+
+
+
+
+
+#[macro_export]
+macro_rules! error {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Error, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Error, $($arg)*);
+ )
+}
+
+
+
+
+
+#[macro_export]
+macro_rules! warn {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Warn, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Warn, $($arg)*);
+ )
+}
+
+
+
+
+
+
+#[macro_export]
+macro_rules! info {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Info, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Info, $($arg)*);
+ )
+}
+
+
+
+
+
+
+#[macro_export]
+macro_rules! debug {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Debug, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Debug, $($arg)*);
+ )
+}
+
+
+
+
+
+
+#[macro_export]
+macro_rules! trace {
+ (target: $target:expr, $($arg:tt)*) => (
+ log!(target: $target, $crate::LogLevel::Trace, $($arg)*);
+ );
+ ($($arg:tt)*) => (
+ log!($crate::LogLevel::Trace, $($arg)*);
+ )
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#[macro_export]
+macro_rules! log_enabled {
+ (target: $target:expr, $lvl:expr) => ({
+ let lvl = $lvl;
+ !cfg!(log_level = "off") &&
+ (lvl <= $crate::LogLevel::Error || !cfg!(log_level = "error")) &&
+ (lvl <= $crate::LogLevel::Warn || !cfg!(log_level = "warn")) &&
+ (lvl <= $crate::LogLevel::Debug || !cfg!(log_level = "debug")) &&
+ (lvl <= $crate::LogLevel::Info || !cfg!(log_level = "info")) &&
+ lvl <= $crate::max_log_level() &&
+ $crate::__enabled(lvl, $target)
+ });
+ ($lvl:expr) => (log_enabled!(target: module_path!(), $lvl))
+}
+
+
+