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
// Copyright 2017 Dmytro Milinevskyi <dmilinevskyi@gmail.com>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![warn(missing_docs)]

//! # Woodpecker - fast and extensible logger for Rust
//!
//! The main goal of `woodpecker` is to be incredibly fast, extensible and easy to use.
//!
//! Please check out the project [homepage](https://github.com/niamster/woodpecker)
//! for more details on features, issues and limitation.
//!
//! The log levels are treated in a hierarchical manner.
//!
//! If there's no exact match for a requested log then the closest match is used.
//!
//! That means that the log level for `foo::bar::qux` is deduced from the log level
//! for `foo::bar` unless the log level for `foo::bar::qux` is explicitly set.
//!
//! See documentation for the [wp_get_level](macro.wp_get_level.html) and [log](macro.log.html)
//! macros for more details on the hierarchy.
//!
//! # Installation
//! To start using `woodpecker` just enable it in your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! woodpecker = "0.4"
//! ```
//!
//! In the very beginning `woodpecker` should be configured using [wp_init](macro.wp_init!.html) macro.
//! By default [WARN](levels/enum.LogLevel.html) is used.
//! The usual logging macros as `debug`, `info`, etc. are available
//! as with generic rust [logger](https://doc.rust-lang.org/log).
//!
//! # Example
//!
//! ```rust
//! #[macro_use]
//! extern crate woodpecker;
//! use woodpecker as wp;
//!
//! fn main() {
//!     wp_init!();
//!     wp_set_level!(wp::LogLevel::INFO).unwrap();
//!
//!     info!("{} is saying hello", "woodpecker");
//!     debug!("I'm invisible");
//! }
//!
//! ```
//!
//! Woodpecker supports logging in a dedicated thread.
//!
//! This frees the application from the latency caused by the overhead of log string
//! formatter and the log drain(terminal, file, network, etc.).
//!
//! It's important to use [sync](fn.sync.html) in the end of the `main` funtion
//! to ensure that all log records are properly flushed.
//!
//! The logging thread could be activated via a configuration parameter passed
//! to the [wp_init](macro.wp_init!.html) macro.
//! The `WP_LOG_THREAD` environment variable may be used overrides compile-time settings.

#[macro_use]
extern crate lazy_static;

#[doc(hidden)]
#[macro_use]
pub mod macros;

#[doc(hidden)]
pub mod config;
#[doc(inline)]
pub use config::Config;

/// Definition of the log levels.
pub mod levels;
#[doc(inline)]
pub use levels::LogLevel;

/// Definition of the log record entry.
pub mod record;
#[doc(inline)]
pub use record::Record;

/// The logger core.
#[macro_use]
pub mod logger;
#[doc(inline)]
pub use logger::{init, sync};

#[doc(hidden)]
pub mod line_range;
#[doc(inline)]
pub use line_range::LineRangeBound;
pub use line_range::LineRangeBound::{BOF, EOF};

/// Collection of log handlers.
pub mod handlers;

/// Collection of log record formatters.
pub mod formatters;

#[doc(hidden)]
pub mod global;

#[doc(inline)]
pub mod spec;