slog-term-2.6.0/.cargo_vcs_info.json0000644000000001121366412511300130440ustar00{ "git": { "sha1": "5be2ff4895464b425c70a324302f9e9501d6a301" } } slog-term-2.6.0/.editorconfig010064400017500001750000000001111335077454100143300ustar0000000000000000root = true [*.rs] charset = utf-8 indent_style = space indent_size = 4 slog-term-2.6.0/.gitignore010064400017500001750000000000611335077454100136470ustar0000000000000000/target /Cargo.lock /tags /.cargo /rusty-tags.vi slog-term-2.6.0/.rustfmt.toml010064400017500001750000000000461335077454100143410ustar0000000000000000max_width = 80 reorder_imports = true slog-term-2.6.0/.travis.yml010064400017500001750000000010241355476707300140000ustar0000000000000000language: rust rust: - stable - beta - nightly - 1.32.0 script: - make all - make travistest - if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then make bench ; fi env: global: - RUST_BACKTRACE=1 matrix: - - RELEASE=true notifications: webhooks: urls: - https://webhooks.gitter.im/e/6d8e17dd2fa83b143168 on_success: change # options: [always|never|change] default: always on_failure: change # options: [always|never|change] default: always on_start: false # default: false slog-term-2.6.0/.vimrc010064400017500001750000000001671335077454100130070ustar0000000000000000let g:rustfmt_autosave = 1 autocmd BufEnter *.rs setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=80 slog-term-2.6.0/CHANGELOG.md010064400017500001750000000066651366400337400135050ustar0000000000000000# Change Log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## 2.6.0 - 2020-05-28 * Fix detection of terminals without color support * Add support for slog/nested-values * Documentation fixes ## 2.5.0 - 2020-01-29 * Upgrade to thread_local 1 * Fix `clippy` warnings on 2018 edition * Cargo.toml - 2018 edition ## 2.4.2 - 2019-10-25 ### Changed Make public the following elements to be able to reuse for your own implementations: * `print_msg_header` * `Serializer` * `Serializer::new` * `Serializer.finish()` * `CompactFormatSerializer` * `CompactFormatSerializer::new` * `CompactFormatSerializer.finish()` * `CountingWriter` * `CountingWriter::new` * `CountingWriter.count()` ## 2.4.1 - 2019-07-10 ### Changed * Lazily evaluate color detection (GH-214). ## 2.4.0 - 2018-04-13 ### Changed * Bump `term` dependency ## 2.3.0 - 2017-08-26 ### Changed * Change semantics of `TermDecorator::build` that didn't make sense before. ## 2.2.0 - 2017-08-26 ### Added * `use_original_order` for `FullFormat` ## 2.1.0 - 2017-08-05 ### Added * Writer that plays nicely with unit tests ## 2.0.4 - 2017-07-03 ### Changed * Improved documentation * Relicense under MPL/Apache/MIT ## 2.0.1 - 2017-05-08 ### Changed * Fix commas on empty message ## 2.0.0 - 2017-04-29 ### Changed * Just release major version ## 2.0.0-4.0 - 2017-04-11 ### Changed * Update slog dependency ## 2.0.0-3.0 - 2017-03-27 ### Changed * Update slog dependency ## 2.0.0-2.1 - 2017-03-16 ### Fixed * `TermDecoratorBuilder::build()` will not panic anymore * `TermDecorator` will automatically detect if colors should be used * Add helper functions for drains with default settings ### Added * Color settings for `TermDecorator` * `TermDecoratorBuilder::try_build()` that returns `Option` ## 2.0.0-2.0 - 2017-03-11 ### Changed * Full rewrite, ditch `slog-stream` * Use `term` so should work on Linux and Windows shells out of the box * Allow extending (eg. for `termion` and other terminal crates) * Compact mode now prints one value per line. Groups are not exposed by `slog` anymore. ## 1.5.0 - 2017-02-05 ### Change * Reverse the order of record values in full mode to match slog 1.5 definition ## 1.4.0 - 2017-01-29 ### Changed * Fix a bug in `new_plain` that would make it still use colors. * No comma will be printed after an empty "msg" field * Changed order of full format values ## 1.3.5 - 2016-01-13 ### Fixed * [1.3.4 with `?` operator breaks semver](https://github.com/slog-rs/term/issues/6) - fix allows builds on stable Rust back to 1.11 ## 1.3.4 - 2016-12-27 ### Fixed * [Fix compact formatting grouping messages incorrectly](https://github.com/slog-rs/slog/issues/90) ## 1.3.3 - 2016-10-31 ### Changed * Added `Send+Sync` to `Drain` returned on `build` ## 1.3.2 - 2016-10-22 ### Changed * Fix compact format, repeating some values unnecessarily. ## 1.3.1 - 2016-10-22 ### Changed * Make `Format` public so it can be reused ## 1.3.0 - 2016-10-21 ### Changed * **BREAKING**: Switched `AsyncStramer` to `slog_extra::Async` ## 1.2.0 - 2016-10-17 ### Changed * **BREAKING**: Rewrite handling of owned values. ## 1.1.0 - 2016-09-28 ### Added * Custom timestamp function support ### Changed * Logging level color uses only first 8 ANSI terminal colors for better compatibility ## 1.0.0 - 2016-09-21 First stable release. slog-term-2.6.0/Cargo.lock0000644000000524621366412511300110360ustar00# This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "argon2rs" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "arrayvec" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "blake2-rfc" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "constant_time_eq" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dirs" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "dirs-sys" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "erased-serde" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "nodrop" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "numtoa" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand_os" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_users" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ryu" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "scoped_threadpool" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "slog" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "erased-serde 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "slog-async" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "slog-term" version = "2.6.0" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" version = "0.15.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "take_mut" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "term" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "termion" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "18b50f5258d1a9ad8396d2d345827875de4261b158124d4c819d9b351454fae5" "checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" "checksum erased-serde 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d88b6d1705e16a4d62e05ea61cc0496c2bd190f4fa8e5c1f11ce747be6bcf3d1" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum ryu 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" "checksum serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)" = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c" "checksum serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)" = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" "checksum slog 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36d9e85f8df625a6ac087188d0826546df56e07190bede661c10c95a95890cad" "checksum slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e544d16c6b230d84c866662fe55e31aacfca6ae71e6fc49ae9a311cb379bfc2f" "checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum term 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" slog-term-2.6.0/Cargo.toml0000644000000026341366412511300110550ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "slog-term" version = "2.6.0" authors = ["Dawid Ciężarkiewicz "] description = "Unix terminal drain and formatter for slog-rs" homepage = "https://github.com/slog-rs/slog" documentation = "https://docs.rs/slog-term" readme = "README.md" keywords = ["slog", "logging", "log", "term"] license = "MPL-2.0/MIT/Apache-2.0" repository = "https://github.com/slog-rs/term" [dependencies.atty] version = "0.2" [dependencies.chrono] version = "0.4" [dependencies.erased-serde] version = "0.3" optional = true [dependencies.serde] version = "1.0" optional = true [dependencies.serde_json] version = "1.0" optional = true [dependencies.slog] version = "2" [dependencies.term] version = "0.6" [dependencies.thread_local] version = "1" [dev-dependencies.slog-async] version = "2" [features] nested-values = ["erased-serde", "serde", "serde_json", "slog/nested-values"] slog-term-2.6.0/Cargo.toml.orig010064400017500001750000000014031366400340300145350ustar0000000000000000[package] name = "slog-term" version = "2.6.0" authors = ["Dawid Ciężarkiewicz "] description = "Unix terminal drain and formatter for slog-rs" keywords = ["slog", "logging", "log", "term"] license = "MPL-2.0/MIT/Apache-2.0" documentation = "https://docs.rs/slog-term" homepage = "https://github.com/slog-rs/slog" repository = "https://github.com/slog-rs/term" readme = "README.md" edition = "2018" [features] nested-values = ["erased-serde", "serde", "serde_json", "slog/nested-values"] [dependencies] slog = "2" atty = "0.2" chrono = "0.4" thread_local = "1" term = "0.6" erased-serde = {version = "0.3", optional = true } serde = {version = "1.0", optional = true } serde_json = {version = "1.0", optional = true } [dev-dependencies] slog-async = "2" slog-term-2.6.0/LICENSE-APACHE010064400017500001750000000251371335077454100136160ustar0000000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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. slog-term-2.6.0/LICENSE-MIT010064400017500001750000000020571335077454100133220ustar0000000000000000Copyright (c) 2014 The Rust Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. slog-term-2.6.0/LICENSE-MPL2010064400017500001750000000405261335077454100134060ustar0000000000000000Mozilla Public License Version 2.0 ================================== 1. Definitions -------------- 1.1. "Contributor" means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. 1.2. "Contributor Version" means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. 1.3. "Contribution" means Covered Software of a particular Contributor. 1.4. "Covered Software" means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. 1.5. "Incompatible With Secondary Licenses" means (a) that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or (b) that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License. 1.6. "Executable Form" means any form of the work other than Source Code Form. 1.7. "Larger Work" means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" means this document. 1.9. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. 1.10. "Modifications" means any of the following: (a) any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or (b) any new file in Source Code Form that contains any Covered Software. 1.11. "Patent Claims" of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version. 1.12. "Secondary License" means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. 1.13. "Source Code Form" means the form of the work preferred for making modifications. 1.14. "You" (or "Your") means an individual or a legal entity exercising rights under this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. License Grants and Conditions -------------------------------- 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: (a) under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and (b) under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: (a) for any code that a Contributor has removed from Covered Software; or (b) for infringements caused by: (i) Your and any other third party's modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or (c) under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. 3. Responsibilities ------------------- 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: (a) such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and (b) You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. 4. Inability to Comply Due to Statute or Regulation --------------------------------------------------- If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Termination -------------- 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. ************************************************************************ * * * 6. Disclaimer of Warranty * * ------------------------- * * * * Covered Software is provided under this License on an "as is" * * basis, without warranty of any kind, either expressed, implied, or * * statutory, including, without limitation, warranties that the * * Covered Software is free of defects, merchantable, fit for a * * particular purpose or non-infringing. The entire risk as to the * * quality and performance of the Covered Software is with You. * * Should any Covered Software prove defective in any respect, You * * (not any Contributor) assume the cost of any necessary servicing, * * repair, or correction. This disclaimer of warranty constitutes an * * essential part of this License. No use of any Covered Software is * * authorized under this License except under this disclaimer. * * * ************************************************************************ ************************************************************************ * * * 7. Limitation of Liability * * -------------------------- * * * * Under no circumstances and under no legal theory, whether tort * * (including negligence), contract, or otherwise, shall any * * Contributor, or anyone who distributes Covered Software as * * permitted above, be liable to You for any direct, indirect, * * special, incidental, or consequential damages of any character * * including, without limitation, damages for lost profits, loss of * * goodwill, work stoppage, computer failure or malfunction, or any * * and all other commercial damages or losses, even if such party * * shall have been informed of the possibility of such damages. This * * limitation of liability shall not apply to liability for death or * * personal injury resulting from such party's negligence to the * * extent applicable law prohibits such limitation. Some * * jurisdictions do not allow the exclusion or limitation of * * incidental or consequential damages, so this exclusion and * * limitation may not apply to You. * * * ************************************************************************ 8. Litigation ------------- Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. 9. Miscellaneous ---------------- This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. 10. Versions of the License --------------------------- 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. Exhibit A - Source Code Form License Notice ------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. You may add additional accurate notices of copyright ownership. Exhibit B - "Incompatible With Secondary Licenses" Notice --------------------------------------------------------- This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. slog-term-2.6.0/Makefile010064400017500001750000000027561335077454100133340ustar0000000000000000PKG_NAME=$(shell grep name Cargo.toml | head -n 1 | awk -F \" '{print $$2}') DOCS_DEFAULT_MODULE=$(subst -,_,$(PKG_NAME)) ifeq (, $(shell which cargo-check 2> /dev/null)) DEFAULT_TARGET=build else DEFAULT_TARGET=build endif default: $(DEFAULT_TARGET) ALL_TARGETS += build $(EXAMPLES) test doc ifneq ($(RELEASE),) $(info RELEASE BUILD: $(PKG_NAME)) CARGO_FLAGS += --release else $(info DEBUG BUILD: $(PKG_NAME); use `RELEASE=true make [args]` for release build) endif EXAMPLES = $(shell cd examples 2>/dev/null && ls *.rs 2>/dev/null | sed -e 's/.rs$$//g' ) all: $(ALL_TARGETS) .PHONY: run test build doc clean clippy run test build clean: cargo $@ $(CARGO_FLAGS) check: $(info Running check; use `make build` to actually build) cargo $@ $(CARGO_FLAGS) clippy: cargo build --features clippy .PHONY: bench bench: cargo $@ $(filter-out --release,$(CARGO_FLAGS)) .PHONY: travistest travistest: test .PHONY: longtest longtest: @echo "Running longtest. Press Ctrl+C to stop at any time" @sleep 2 @i=0; while i=$$((i + 1)) && echo "Iteration $$i" && make test ; do :; done .PHONY: $(EXAMPLES) $(EXAMPLES): cargo build --example $@ $(CARGO_FLAGS) .PHONY: doc doc: FORCE cargo doc .PHONY: publishdoc publishdoc: rm -rf target/doc make doc echo '' > target/doc/index.html ghp-import -n target/doc git push -f origin gh-pages .PHONY: docview docview: doc xdg-open target/doc/$(PKG_NAME)/index.html .PHONY: FORCE FORCE: slog-term-2.6.0/README.md010064400017500001750000000014321335077454100131410ustar0000000000000000

slog-rs logo
Travis CI Build Status slog-term on crates.io slog-rs Gitter Chat

# slog-term - Terminal output drain for [slog-rs] For more information, help, to report issues etc. see [slog-rs][slog-rs]. [slog-rs]: //github.com/slog-rs/slog slog-term-2.6.0/examples/common/mod.rs010064400017500001750000000014601335077454100161160ustar0000000000000000use slog::*; pub fn simulate_server(log: Logger) { let server = log.new(o!("host" => "localhost", "port" => "8080")); let peer1 = server.new(o!("peer_addr" => "8.8.8.8", "port" => "18230")); let peer2 = server.new(o!("peer_addr" => "82.9.9.9", "port" => "42381")); info!(server, "starting"); info!(server, "listening"); debug!(peer2, "connected"); debug!(peer2, "message received"; "length" => 2); debug!(peer1, "connected"); warn!(peer2, "weak encryption requested"; "algo" => "xor"); debug!(peer2, "response sent"; "length" => 8); debug!(peer2, "disconnected"); debug!(peer1, "message received"; "length" => 2); debug!(peer1, "response sent"; "length" => 8); debug!(peer1, "disconnected"); crit!(server, "internal error"); info!(server, "exit"); } slog-term-2.6.0/examples/compact-color.rs010064400017500001750000000006501335077454100166110ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; mod common; fn main() { let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::CompactFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let log = slog::Logger::root(drain, o!("version" => "0.5")); common::simulate_server(log); } slog-term-2.6.0/examples/compact.rs010064400017500001750000000006621335077454100155000ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; mod common; fn main() { let decorator = slog_term::PlainDecorator::new(std::io::stdout()); let drain = slog_term::CompactFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let log = slog::Logger::root(drain, o!("version" => "0.5")); common::simulate_server(log); } slog-term-2.6.0/examples/full-color-oorder.rs010064400017500001750000000007251335077454100174200ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; mod common; fn main() { let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::FullFormat::new(decorator) .use_original_order() .build() .fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let log = slog::Logger::root(drain, o!("version" => "0.5")); common::simulate_server(log); } slog-term-2.6.0/examples/full-color.rs010064400017500001750000000006451335077454100161310ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; mod common; fn main() { let decorator = slog_term::TermDecorator::new().build(); let drain = slog_term::FullFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let log = slog::Logger::root(drain, o!("version" => "0.5")); common::simulate_server(log); } slog-term-2.6.0/examples/full.rs010064400017500001750000000005341335077454100150120ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_term; use slog::Drain; mod common; fn main() { let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout()); let drain = slog_term::FullFormat::new(decorator).build().fuse(); let log = slog::Logger::root(drain, o!("version" => "0.5")); common::simulate_server(log); } slog-term-2.6.0/examples/to-file.rs010064400017500001750000000011221335077454100154010ustar0000000000000000#[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; use std::fs::OpenOptions; fn main() { let log_path = "your_log_file_path.log"; let file = OpenOptions::new() .create(true) .write(true) .truncate(true) .open(log_path) .unwrap(); let decorator = slog_term::PlainDecorator::new(file); let drain = slog_term::FullFormat::new(decorator).build().fuse(); let drain = slog_async::Async::new(drain).build().fuse(); let _log = slog::Logger::root(drain, o!()); info!(_log, "foo!"); } slog-term-2.6.0/src/lib.rs010064400017500001750000001200371366400323200135560ustar0000000000000000// {{{ Module docs //! `slog-rs`'s `Drain` for terminal output //! //! This crate implements output formatting targeting logging to //! terminal/console/shell or similar text-based IO. //! //! **Warning**: `slog-term` (like `slog-rs` itself) is fast, modular and //! extensible. It comes with a price: a lot of details (*that you don't care //! about //! right now and think they are stupid, until you actually do and then you are //! happy that someone thought of them for you*) are being taken into //! consideration. Anyway, **if you just want to get a logging to terminal //! working with `slog`**, consider using a wrapper crate like //! [sloggers](https://docs.rs/sloggers/) instead. //! //! **Note**: A lot of users gets bitten by the fact that //! `slog::Logger::root(...)` requires a drain that is //! safe to send and share across threads (`Send+Sync`). With shared resource //! like terminal or a file to which you log, a synchronization needs to be //! taken care of. If you get compilation errors around `Sync` or `Send` you //! are doing something wrong around it. //! //! Using `Decorator` open trait, user can implement outputting //! using different colors, terminal types and so on. //! //! # Synchronization via `PlainSyncDecorator` //! //! This logger works by synchronizing on the IO directly in //! `PlainSyncDecorator`. The formatting itself is thread-safe. //! //! ``` //! use slog::*; //! //! let plain = slog_term::PlainSyncDecorator::new(std::io::stdout()); //! let logger = Logger::root( //! slog_term::FullFormat::new(plain) //! .build().fuse(), o!() //! ); //! //! info!(logger, "Logging ready!"); //! ``` //! //! # Synchronization via `slog_async` //! //! This drain puts logging into a separate thread via `slog_async::Async`: //! formatting and writing to terminal is happening in a one dedicated thread, //! so no further synchronization is required. //! //! ``` //! use slog::{Drain, o, info}; //! //! let decorator = slog_term::TermDecorator::new().build(); //! let drain = slog_term::CompactFormat::new(decorator).build().fuse(); //! let drain = slog_async::Async::new(drain).build().fuse(); //! //! let log = slog::Logger::root(drain, o!()); //! //! info!(log, "Logging ready!"); //! ``` //! //! # Synchronization via `Mutex` //! //! This drain synchronizes by wrapping everything in a big mutex (yes, //! `Mutex` implements a `Drain` trait). This is kind of slow, but in //! scripting languages like Ruby or Python pretty much the whole code is //! running in a one //! huge mutex and noone seems to mind, so I'm sure you're going to get away //! with this. Personally, I am a bit sad, that I've spent so much effort to //! give you tools to make your code as efficient as possible, and you choose //! this. ಠ_ಠ . But I'm here to serve, not to tell you what to do. //! //! ``` //! use slog::{Drain, o, info}; //! //! let decorator = slog_term::TermDecorator::new().build(); //! let drain = slog_term::CompactFormat::new(decorator).build(); //! let drain = std::sync::Mutex::new(drain).fuse(); //! //! let log = slog::Logger::root(drain, o!()); //! //! info!(log, "Logging ready!"); //! ``` // }}} // {{{ Imports & meta #![warn(missing_docs)] use slog::Drain; use slog::Key; use slog::*; use std::cell::RefCell; use std::io::Write as IoWrite; use std::panic::{RefUnwindSafe, UnwindSafe}; use std::result; use std::{fmt, io, mem, sync}; // }}} // {{{ Decorator /// Output decorator /// /// Trait implementing strategy of output formating in terms of IO, /// colors, etc. pub trait Decorator { /// Get a `RecordDecorator` for a given `record` /// /// This allows `Decorator` to have on-stack data per processed `Record`s /// fn with_record( &self, _record: &Record, _logger_values: &OwnedKVList, f: F, ) -> io::Result<()> where F: FnOnce(&mut dyn RecordDecorator) -> io::Result<()>; } impl Decorator for Box where T: Decorator, { fn with_record( &self, record: &Record, logger_kv: &OwnedKVList, f: F, ) -> io::Result<()> where F: FnOnce(&mut dyn RecordDecorator) -> io::Result<()>, { (**self).with_record(record, logger_kv, f) } } /// Per-record decorator pub trait RecordDecorator: io::Write { /// Reset formatting to defaults fn reset(&mut self) -> io::Result<()>; /// Format normal text fn start_whitespace(&mut self) -> io::Result<()> { self.reset() } /// Format `Record` message fn start_msg(&mut self) -> io::Result<()> { self.reset() } /// Format timestamp fn start_timestamp(&mut self) -> io::Result<()> { self.reset() } /// Format `Record` level fn start_level(&mut self) -> io::Result<()> { self.reset() } /// Format a comma between key-value pairs fn start_comma(&mut self) -> io::Result<()> { self.reset() } /// Format key fn start_key(&mut self) -> io::Result<()> { self.reset() } /// Format a value fn start_value(&mut self) -> io::Result<()> { self.reset() } /// Format value fn start_separator(&mut self) -> io::Result<()> { self.reset() } } impl RecordDecorator for Box { fn reset(&mut self) -> io::Result<()> { (**self).reset() } fn start_whitespace(&mut self) -> io::Result<()> { (**self).start_whitespace() } /// Format `Record` message fn start_msg(&mut self) -> io::Result<()> { (**self).start_msg() } /// Format timestamp fn start_timestamp(&mut self) -> io::Result<()> { (**self).start_timestamp() } /// Format `Record` level fn start_level(&mut self) -> io::Result<()> { (**self).start_level() } /// Format `Record` message fn start_comma(&mut self) -> io::Result<()> { (**self).start_comma() } /// Format key fn start_key(&mut self) -> io::Result<()> { (**self).start_key() } /// Format value fn start_value(&mut self) -> io::Result<()> { (**self).start_value() } /// Format value fn start_separator(&mut self) -> io::Result<()> { (**self).start_separator() } } // }}} // {{{ Misc /// Returns `true` if message was not empty pub fn print_msg_header( fn_timestamp: &dyn ThreadSafeTimestampFn>, mut rd: &mut dyn RecordDecorator, record: &Record, ) -> io::Result { rd.start_timestamp()?; fn_timestamp(&mut rd)?; rd.start_whitespace()?; write!(rd, " ")?; rd.start_level()?; write!(rd, "{}", record.level().as_short_str())?; rd.start_whitespace()?; write!(rd, " ")?; rd.start_msg()?; let mut count_rd = CountingWriter::new(&mut rd); write!(count_rd, "{}", record.msg())?; Ok(count_rd.count() != 0) } // }}} // {{{ Term /// Terminal-output formatting `Drain` /// /// **Note**: logging to `FullFormat` drain is thread-safe, since every /// line of output is formatted indecently. However, the underlying /// IO, needs to be synchronized. pub struct FullFormat where D: Decorator, { decorator: D, fn_timestamp: Box>>, use_original_order: bool, } /// Streamer builder pub struct FullFormatBuilder where D: Decorator, { decorator: D, fn_timestamp: Box>>, original_order: bool, } impl FullFormatBuilder where D: Decorator, { /// Use the UTC time zone for the timestamp pub fn use_utc_timestamp(mut self) -> Self { self.fn_timestamp = Box::new(timestamp_utc); self } /// Use the local time zone for the timestamp (default) pub fn use_local_timestamp(mut self) -> Self { self.fn_timestamp = Box::new(timestamp_local); self } /// Provide a custom function to generate the timestamp pub fn use_custom_timestamp(mut self, f: F) -> Self where F: ThreadSafeTimestampFn, { self.fn_timestamp = Box::new(f); self } /// Use the original ordering of key-value pairs /// /// By default, key-values are printed in a reversed order. This option will /// change it to the order in which key-values were added. pub fn use_original_order(mut self) -> Self { self.original_order = true; self } /// Build `FullFormat` pub fn build(self) -> FullFormat { FullFormat { decorator: self.decorator, fn_timestamp: self.fn_timestamp, use_original_order: self.original_order, } } } impl Drain for FullFormat where D: Decorator, { type Ok = (); type Err = io::Error; fn log( &self, record: &Record, values: &OwnedKVList, ) -> result::Result { self.format_full(record, values) } } impl FullFormat where D: Decorator, { /// New `TermBuilder` #[allow(clippy::new_ret_no_self)] pub fn new(d: D) -> FullFormatBuilder { FullFormatBuilder { fn_timestamp: Box::new(timestamp_local), decorator: d, original_order: false, } } fn format_full( &self, record: &Record, values: &OwnedKVList, ) -> io::Result<()> { self.decorator.with_record(record, values, |decorator| { let comma_needed = print_msg_header(&*self.fn_timestamp, decorator, record)?; { let mut serializer = Serializer::new( decorator, comma_needed, self.use_original_order, ); record.kv().serialize(record, &mut serializer)?; values.serialize(record, &mut serializer)?; serializer.finish()?; } decorator.start_whitespace()?; writeln!(decorator)?; decorator.flush()?; Ok(()) }) } } // }}} // {{{ CompactFormat /// Compact terminal-output formatting `Drain` /// /// **Note**: Compact logging format is not `Sync` (thread-safe) and needs to be /// synchronized externally, as current output depends on the previous one. /// /// Put it into a `std::sync::Mutex` or `slog_async::Async` worker-thread to /// serialize accesses to it. pub struct CompactFormat where D: Decorator, { decorator: D, history: RefCell, Vec)>>, fn_timestamp: Box>>, } /// Streamer builder pub struct CompactFormatBuilder where D: Decorator, { decorator: D, fn_timestamp: Box>>, } impl CompactFormatBuilder where D: Decorator, { /// Use the UTC time zone for the timestamp pub fn use_utc_timestamp(mut self) -> Self { self.fn_timestamp = Box::new(timestamp_utc); self } /// Use the local time zone for the timestamp (default) pub fn use_local_timestamp(mut self) -> Self { self.fn_timestamp = Box::new(timestamp_local); self } /// Provide a custom function to generate the timestamp pub fn use_custom_timestamp(mut self, f: F) -> Self where F: ThreadSafeTimestampFn, { self.fn_timestamp = Box::new(f); self } /// Build the streamer pub fn build(self) -> CompactFormat { CompactFormat { decorator: self.decorator, fn_timestamp: self.fn_timestamp, history: RefCell::new(vec![]), } } } impl Drain for CompactFormat where D: Decorator, { type Ok = (); type Err = io::Error; fn log( &self, record: &Record, values: &OwnedKVList, ) -> result::Result { self.format_compact(record, values) } } impl CompactFormat where D: Decorator, { /// New `CompactFormatBuilder` #[allow(clippy::new_ret_no_self)] pub fn new(d: D) -> CompactFormatBuilder { CompactFormatBuilder { fn_timestamp: Box::new(timestamp_local), decorator: d, } } fn format_compact( &self, record: &Record, values: &OwnedKVList, ) -> io::Result<()> { self.decorator.with_record(record, values, |decorator| { let indent = { let mut history_ref = self.history.borrow_mut(); let mut serializer = CompactFormatSerializer::new(decorator, &mut *history_ref); values.serialize(record, &mut serializer)?; serializer.finish()? }; decorator.start_whitespace()?; for _ in 0..indent { write!(decorator, " ")?; } let comma_needed = print_msg_header(&*self.fn_timestamp, decorator, record)?; { let mut serializer = Serializer::new(decorator, comma_needed, false); record.kv().serialize(record, &mut serializer)?; serializer.finish()?; } decorator.start_whitespace()?; writeln!(decorator)?; decorator.flush()?; Ok(()) }) } } // }}} // {{{ Serializer /// Serializer for the lines pub struct Serializer<'a> { comma_needed: bool, decorator: &'a mut dyn RecordDecorator, reverse: bool, stack: Vec<(String, String)>, } impl<'a> Serializer<'a> { /// Create `Serializer` instance pub fn new( d: &'a mut dyn RecordDecorator, comma_needed: bool, reverse: bool, ) -> Self { Serializer { comma_needed, decorator: d, reverse, stack: vec![], } } fn maybe_print_comma(&mut self) -> io::Result<()> { if self.comma_needed { self.decorator.start_comma()?; write!(self.decorator, ", ")?; } self.comma_needed |= true; Ok(()) } /// Write out all the whole stack pub fn finish(mut self) -> io::Result<()> { loop { if let Some((k, v)) = self.stack.pop() { self.maybe_print_comma()?; self.decorator.start_key()?; write!(self.decorator, "{}", k)?; write!(self.decorator, ":")?; self.decorator.start_whitespace()?; write!(self.decorator, " ")?; self.decorator.start_value()?; write!(self.decorator, "{}", v)?; } else { return Ok(()); } } } } impl<'a> Drop for Serializer<'a> { fn drop(&mut self) { if !self.stack.is_empty() { panic!("stack not empty"); } } } macro_rules! s( ($s:expr, $k:expr, $v:expr) => { if $s.reverse { $s.stack.push(($k.into(), format!("{}", $v))); } else { $s.maybe_print_comma()?; $s.decorator.start_key()?; write!($s.decorator, "{}", $k)?; $s.decorator.start_separator()?; write!($s.decorator, ":")?; $s.decorator.start_whitespace()?; write!($s.decorator, " ")?; $s.decorator.start_value()?; write!($s.decorator, "{}", $v)?; } }; ); impl<'a> slog::ser::Serializer for Serializer<'a> { fn emit_none(&mut self, key: Key) -> slog::Result { s!(self, key, "None"); Ok(()) } fn emit_unit(&mut self, key: Key) -> slog::Result { s!(self, key, "()"); Ok(()) } fn emit_bool(&mut self, key: Key, val: bool) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_char(&mut self, key: Key, val: char) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_usize(&mut self, key: Key, val: usize) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_isize(&mut self, key: Key, val: isize) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_u8(&mut self, key: Key, val: u8) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_i8(&mut self, key: Key, val: i8) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_u16(&mut self, key: Key, val: u16) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_i16(&mut self, key: Key, val: i16) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_u32(&mut self, key: Key, val: u32) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_i32(&mut self, key: Key, val: i32) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_f32(&mut self, key: Key, val: f32) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_u64(&mut self, key: Key, val: u64) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_i64(&mut self, key: Key, val: i64) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_f64(&mut self, key: Key, val: f64) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_str(&mut self, key: Key, val: &str) -> slog::Result { s!(self, key, val); Ok(()) } fn emit_arguments( &mut self, key: Key, val: &fmt::Arguments, ) -> slog::Result { s!(self, key, val); Ok(()) } #[cfg(feature = "nested-values")] fn emit_serde( &mut self, key: Key, val: &dyn slog::SerdeValue, ) -> slog::Result { let mut writer = Vec::new(); serde::ser::Serialize::serialize( val.as_serde(), &mut serde_json::Serializer::new(&mut writer), ) .map_err(|e| std::io::Error::from(e))?; let val = std::str::from_utf8(&writer).expect("serde JSON is always UTF-8"); s!(self, key, val); Ok(()) } } // }}} // {{{ CompactFormatSerializer /// The Compact format serializer pub struct CompactFormatSerializer<'a> { decorator: &'a mut dyn RecordDecorator, history: &'a mut Vec<(Vec, Vec)>, buf: Vec<(Vec, Vec)>, } impl<'a> CompactFormatSerializer<'a> { /// Create `CompactFormatSerializer` instance pub fn new( d: &'a mut dyn RecordDecorator, history: &'a mut Vec<(Vec, Vec)>, ) -> Self { CompactFormatSerializer { decorator: d, history, buf: vec![], } } /// Write out all the whole stack pub fn finish(&mut self) -> io::Result { let mut indent = 0; for mut buf in self.buf.drain(..).rev() { let (print, trunc, push) = if let Some(prev) = self.history.get_mut(indent) { if *prev != buf { *prev = mem::replace(&mut buf, (vec![], vec![])); (true, true, false) } else { (false, false, false) } } else { (true, false, true) }; if push { self.history.push(mem::replace(&mut buf, (vec![], vec![]))); } if trunc { self.history.truncate(indent + 1); } if print { let &(ref k, ref v) = self.history.get(indent).expect("assertion failed"); self.decorator.start_whitespace()?; for _ in 0..indent { write!(self.decorator, " ")?; } self.decorator.start_key()?; self.decorator.write_all(k)?; self.decorator.start_separator()?; write!(self.decorator, ":")?; self.decorator.start_whitespace()?; write!(self.decorator, " ")?; self.decorator.start_value()?; self.decorator.write_all(v)?; self.decorator.start_whitespace()?; writeln!(self.decorator)?; } indent += 1; } Ok(indent) } } macro_rules! cs( ($s:expr, $k:expr, $v:expr) => { let mut k = vec!(); let mut v = vec!(); write!(&mut k, "{}", $k)?; write!(&mut v, "{}", $v)?; $s.buf.push((k, v)); }; ); impl<'a> slog::ser::Serializer for CompactFormatSerializer<'a> { fn emit_none(&mut self, key: Key) -> slog::Result { cs!(self, key, "None"); Ok(()) } fn emit_unit(&mut self, key: Key) -> slog::Result { cs!(self, key, "()"); Ok(()) } fn emit_bool(&mut self, key: Key, val: bool) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_char(&mut self, key: Key, val: char) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_usize(&mut self, key: Key, val: usize) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_isize(&mut self, key: Key, val: isize) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_u8(&mut self, key: Key, val: u8) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_i8(&mut self, key: Key, val: i8) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_u16(&mut self, key: Key, val: u16) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_i16(&mut self, key: Key, val: i16) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_u32(&mut self, key: Key, val: u32) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_i32(&mut self, key: Key, val: i32) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_f32(&mut self, key: Key, val: f32) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_u64(&mut self, key: Key, val: u64) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_i64(&mut self, key: Key, val: i64) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_f64(&mut self, key: Key, val: f64) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_str(&mut self, key: Key, val: &str) -> slog::Result { cs!(self, key, val); Ok(()) } fn emit_arguments( &mut self, key: Key, val: &fmt::Arguments, ) -> slog::Result { cs!(self, key, val); Ok(()) } } // }}} // {{{ CountingWriter /// Wrapper for `Write` types that counts total bytes written. pub struct CountingWriter<'a> { wrapped: &'a mut dyn io::Write, count: usize, } impl<'a> CountingWriter<'a> { /// Create `CountingWriter` instance pub fn new(wrapped: &'a mut dyn io::Write) -> CountingWriter { CountingWriter { wrapped, count: 0 } } /// Returns the count of the total bytes written. pub fn count(&self) -> usize { self.count } } impl<'a> io::Write for CountingWriter<'a> { fn write(&mut self, buf: &[u8]) -> io::Result { self.wrapped.write(buf).map(|n| { self.count += n; n }) } fn flush(&mut self) -> io::Result<()> { self.wrapped.flush() } fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { self.wrapped.write_all(buf).map(|_| { self.count += buf.len(); }) } } // }}} // {{{ Timestamp /// Threadsafe timestamp formatting function type /// /// To satify `slog-rs` thread and unwind safety requirements, the /// bounds expressed by this trait need to satisfied for a function /// to be used in timestamp formatting. pub trait ThreadSafeTimestampFn: Fn(&mut dyn io::Write) -> io::Result<()> + Send + Sync + UnwindSafe + RefUnwindSafe + 'static { } impl ThreadSafeTimestampFn for F where F: Fn(&mut dyn io::Write) -> io::Result<()> + Send + Sync, F: UnwindSafe + RefUnwindSafe + 'static, F: ?Sized, { } const TIMESTAMP_FORMAT: &str = "%b %d %H:%M:%S%.3f"; /// Default local timezone timestamp function /// /// The exact format used, is still subject to change. pub fn timestamp_local(io: &mut dyn io::Write) -> io::Result<()> { write!(io, "{}", chrono::Local::now().format(TIMESTAMP_FORMAT)) } /// Default UTC timestamp function /// /// The exact format used, is still subject to change. pub fn timestamp_utc(io: &mut dyn io::Write) -> io::Result<()> { write!(io, "{}", chrono::Utc::now().format(TIMESTAMP_FORMAT)) } // }}} // {{{ Plain /// Plain (no-op) `Decorator` implementation /// /// This decorator doesn't do any coloring, and doesn't do any synchronization /// between threads, so is not `Sync`. It is however useful combined with /// `slog_async::Async` drain, as `slog_async::Async` uses only one thread, /// and thus requires only `Send` from `Drain`s it wraps. /// /// ``` /// use slog::*; /// use slog_async::Async; /// /// let decorator = slog_term::PlainDecorator::new(std::io::stdout()); /// let drain = Async::new( /// slog_term::FullFormat::new(decorator).build().fuse() /// ) /// .build() /// .fuse(); /// ``` pub struct PlainDecorator(RefCell) where W: io::Write; impl PlainDecorator where W: io::Write, { /// Create `PlainDecorator` instance pub fn new(io: W) -> Self { PlainDecorator(RefCell::new(io)) } } impl Decorator for PlainDecorator where W: io::Write, { fn with_record( &self, _record: &Record, _logger_values: &OwnedKVList, f: F, ) -> io::Result<()> where F: FnOnce(&mut dyn RecordDecorator) -> io::Result<()>, { f(&mut PlainRecordDecorator(&self.0)) } } /// Record decorator used by `PlainDecorator` pub struct PlainRecordDecorator<'a, W: 'a>(&'a RefCell) where W: io::Write; impl<'a, W> io::Write for PlainRecordDecorator<'a, W> where W: io::Write, { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.borrow_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.0.borrow_mut().flush() } } impl<'a, W> Drop for PlainRecordDecorator<'a, W> where W: io::Write, { fn drop(&mut self) { let _ = self.flush(); } } impl<'a, W> RecordDecorator for PlainRecordDecorator<'a, W> where W: io::Write, { fn reset(&mut self) -> io::Result<()> { Ok(()) } } // }}} // {{{ PlainSync /// PlainSync `Decorator` implementation /// /// This implementation is exactly like `PlainDecorator` but it takes care /// of synchronizing writes to `io`. /// /// ``` /// use slog::*; /// /// let plain = slog_term::PlainSyncDecorator::new(std::io::stdout()); /// let root = Logger::root( /// slog_term::FullFormat::new(plain).build().fuse(), o!() /// ); /// ``` pub struct PlainSyncDecorator(sync::Arc>) where W: io::Write; impl PlainSyncDecorator where W: io::Write, { /// Create `PlainSyncDecorator` instance pub fn new(io: W) -> Self { PlainSyncDecorator(sync::Arc::new(sync::Mutex::new(io))) } } impl Decorator for PlainSyncDecorator where W: io::Write, { fn with_record( &self, _record: &Record, _logger_values: &OwnedKVList, f: F, ) -> io::Result<()> where F: FnOnce(&mut dyn RecordDecorator) -> io::Result<()>, { f(&mut PlainSyncRecordDecorator { io: self.0.clone(), buf: vec![], }) } } /// `RecordDecorator` used by `PlainSyncDecorator` pub struct PlainSyncRecordDecorator where W: io::Write, { io: sync::Arc>, buf: Vec, } impl io::Write for PlainSyncRecordDecorator where W: io::Write, { fn write(&mut self, buf: &[u8]) -> io::Result { self.buf.write(buf) } fn flush(&mut self) -> io::Result<()> { if self.buf.is_empty() { return Ok(()); } let mut io = self.io.lock().map_err(|_| { io::Error::new(io::ErrorKind::Other, "mutex locking error") })?; io.write_all(&self.buf)?; self.buf.clear(); io.flush() } } impl Drop for PlainSyncRecordDecorator where W: io::Write, { fn drop(&mut self) { let _ = self.flush(); } } impl RecordDecorator for PlainSyncRecordDecorator where W: io::Write, { fn reset(&mut self) -> io::Result<()> { Ok(()) } } // }}} // {{{ TermDecorator /// Any type of a terminal supported by `term` crate // TODO: https://github.com/Stebalien/term/issues/70 enum AnyTerminal { /// Stdout terminal Stdout { term: Box, supports_reset: bool, supports_color: bool, supports_bold: bool, }, /// Stderr terminal Stderr { term: Box, supports_reset: bool, supports_color: bool, supports_bold: bool, }, FallbackStdout, FallbackStderr, } impl AnyTerminal { fn should_use_color(&self) -> bool { match *self { AnyTerminal::Stdout { .. } => atty::is(atty::Stream::Stdout), AnyTerminal::Stderr { .. } => atty::is(atty::Stream::Stderr), AnyTerminal::FallbackStdout => false, AnyTerminal::FallbackStderr => false, } } } /// `TermDecorator` builder pub struct TermDecoratorBuilder { use_stderr: bool, color: Option, } impl TermDecoratorBuilder { fn new() -> Self { TermDecoratorBuilder { use_stderr: true, color: None, } } /// Output to `stderr` pub fn stderr(mut self) -> Self { self.use_stderr = true; self } /// Output to `stdout` pub fn stdout(mut self) -> Self { self.use_stderr = false; self } /// Force colored output pub fn force_color(mut self) -> Self { self.color = Some(true); self } /// Force plain output pub fn force_plain(mut self) -> Self { self.color = Some(false); self } /// Try to build `TermDecorator` /// /// Unlike `build` this will not fall-back to raw `stdout`/`stderr` /// if it wasn't able to use terminal and its features directly /// (eg. if `TERM` env. was not set). pub fn try_build(self) -> Option { let io = if self.use_stderr { term::stderr().map(|t| { let supports_reset = t.supports_reset(); let supports_color = t.supports_color(); let supports_bold = t.supports_attr(term::Attr::Bold); AnyTerminal::Stderr { term: t, supports_reset, supports_color, supports_bold, } }) } else { term::stdout().map(|t| { let supports_reset = t.supports_reset(); let supports_color = t.supports_color(); let supports_bold = t.supports_attr(term::Attr::Bold); AnyTerminal::Stdout { term: t, supports_reset, supports_color, supports_bold, } }) }; io.map(|io| { let use_color = self.color.unwrap_or_else(|| io.should_use_color()); TermDecorator { use_color, term: RefCell::new(io), } }) } /// Build `TermDecorator` /// /// Unlike `try_build` this it will fall-back to using plain `stdout`/`stderr` /// if it wasn't able to use terminal directly. pub fn build(self) -> TermDecorator { let io = if self.use_stderr { term::stderr() .map(|t| { let supports_reset = t.supports_reset(); let supports_color = t.supports_color(); let supports_bold = t.supports_attr(term::Attr::Bold); AnyTerminal::Stderr { term: t, supports_reset, supports_color, supports_bold, } }) .unwrap_or(AnyTerminal::FallbackStderr) } else { term::stdout() .map(|t| { let supports_reset = t.supports_reset(); let supports_color = t.supports_color(); let supports_bold = t.supports_attr(term::Attr::Bold); AnyTerminal::Stdout { term: t, supports_reset, supports_color, supports_bold, } }) .unwrap_or(AnyTerminal::FallbackStdout) }; let use_color = self.color.unwrap_or_else(|| io.should_use_color()); TermDecorator { term: RefCell::new(io), use_color, } } } /// `Decorator` implemented using `term` crate /// /// This decorator will add nice formatting to the logs it's outputting. It's /// based on `term` crate. /// /// It does not deal with serialization so is `!Sync`. Run in a separate thread /// with `slog_async::Async`. pub struct TermDecorator { term: RefCell, use_color: bool, } impl TermDecorator { /// Start building `TermDecorator` #[allow(clippy::new_ret_no_self)] pub fn new() -> TermDecoratorBuilder { TermDecoratorBuilder::new() } /// `Level` color /// /// Standard level to Unix color conversion used by `TermDecorator` pub fn level_to_color(level: slog::Level) -> u16 { match level { Level::Critical => 5, Level::Error => 1, Level::Warning => 3, Level::Info => 2, Level::Debug => 6, Level::Trace => 4, } } } impl Decorator for TermDecorator { fn with_record( &self, record: &Record, _logger_values: &OwnedKVList, f: F, ) -> io::Result<()> where F: FnOnce(&mut dyn RecordDecorator) -> io::Result<()>, { let mut term = self.term.borrow_mut(); let mut deco = TermRecordDecorator { term: &mut *term, level: record.level(), use_color: self.use_color, }; { f(&mut deco) } } } /// Record decorator used by `TermDecorator` pub struct TermRecordDecorator<'a> { term: &'a mut AnyTerminal, level: slog::Level, use_color: bool, } impl<'a> io::Write for TermRecordDecorator<'a> { fn write(&mut self, buf: &[u8]) -> io::Result { match *self.term { AnyTerminal::Stdout { ref mut term, .. } => term.write(buf), AnyTerminal::Stderr { ref mut term, .. } => term.write(buf), AnyTerminal::FallbackStdout => std::io::stdout().write(buf), AnyTerminal::FallbackStderr => std::io::stderr().write(buf), } } fn flush(&mut self) -> io::Result<()> { match *self.term { AnyTerminal::Stdout { ref mut term, .. } => term.flush(), AnyTerminal::Stderr { ref mut term, .. } => term.flush(), AnyTerminal::FallbackStdout => std::io::stdout().flush(), AnyTerminal::FallbackStderr => std::io::stderr().flush(), } } } impl<'a> Drop for TermRecordDecorator<'a> { fn drop(&mut self) { let _ = self.flush(); } } fn term_error_to_io_error(e: term::Error) -> io::Error { match e { term::Error::Io(e) => e, e => io::Error::new(io::ErrorKind::Other, format!("term error: {}", e)), } } impl<'a> RecordDecorator for TermRecordDecorator<'a> { fn reset(&mut self) -> io::Result<()> { if !self.use_color { return Ok(()); } match self.term { &mut AnyTerminal::Stdout { ref mut term, supports_reset, .. } if supports_reset => term.reset(), &mut AnyTerminal::Stderr { ref mut term, supports_reset, .. } if supports_reset => term.reset(), _ => Ok(()), } .map_err(term_error_to_io_error) } fn start_level(&mut self) -> io::Result<()> { if !self.use_color { return Ok(()); } let color = TermDecorator::level_to_color(self.level); match self.term { &mut AnyTerminal::Stdout { ref mut term, supports_color, .. } if supports_color => term.fg(color as term::color::Color), &mut AnyTerminal::Stderr { ref mut term, supports_color, .. } if supports_color => term.fg(color as term::color::Color), _ => Ok(()), } .map_err(term_error_to_io_error) } fn start_key(&mut self) -> io::Result<()> { if !self.use_color { return Ok(()); } match self.term { &mut AnyTerminal::Stdout { ref mut term, supports_color, supports_bold, .. } => { if supports_bold { term.attr(term::Attr::Bold) } else if supports_color { term.fg(term::color::BRIGHT_WHITE) } else { Ok(()) } } &mut AnyTerminal::Stderr { ref mut term, supports_color, supports_bold, .. } => { if supports_bold { term.attr(term::Attr::Bold) } else if supports_color { term.fg(term::color::BRIGHT_WHITE) } else { Ok(()) } } &mut AnyTerminal::FallbackStdout | &mut AnyTerminal::FallbackStderr => Ok(()), } .map_err(term_error_to_io_error) } fn start_msg(&mut self) -> io::Result<()> { // msg is just like key self.start_key() } } // }}} // {{{ TestStdoutWriter /// Replacement for `std::io::stdout()` for when output capturing by rust's test /// harness is required. /// /// # Note /// /// Due to the way that output capturing works in Rust, using this class has no effect /// if the logger is later passed to another thread that is not controlled by Rust's /// testing framework. /// See [rust-lang/rust#42474](https://github.com/rust-lang/rust/issues/42474) for reference. /// /// For this reason, combining this drain with [Async](https://github.com/slog-rs/async), for example, has no effect. /// /// # Example /// /// ``` /// # use slog::{Drain, info, o, Logger}; /// #[test] /// fn test_logger() { /// let logger = { /// let decorator = slog_term::PlainSyncDecorator::new(slog_term::TestStdoutWriter); /// let drain = slog_term::FullFormat::new(decorator).build().fuse(); /// /// Logger::root_typed(drain, o!()) /// }; /// info!(logger, "Hi from logger test"); /// } /// ``` pub struct TestStdoutWriter; impl io::Write for TestStdoutWriter { fn write(&mut self, data: &[u8]) -> io::Result { print!( "{}", std::str::from_utf8(data) .map_err(|x| io::Error::new(io::ErrorKind::InvalidData, x))? ); Ok(data.len()) } fn flush(&mut self) -> io::Result<()> { io::stdout().flush() } } // }}} // {{{ Helpers /// Create a `CompactFormat` drain with default settings pub fn term_compact() -> CompactFormat { let decorator = TermDecorator::new().build(); CompactFormat::new(decorator).build() } /// Create a `FullFormat` drain with default settings pub fn term_full() -> FullFormat { let decorator = TermDecorator::new().build(); FullFormat::new(decorator).build() } // }}} #[cfg(test)] mod tests { use super::*; #[test] fn test_logger() { let logger = { let decorator = PlainSyncDecorator::new(TestStdoutWriter); let drain = FullFormat::new(decorator).build().fuse(); slog::Logger::root_typed(drain, o!()) }; info!(logger, "Hi from logger test"); } } // vim: foldmethod=marker foldmarker={{{,}}} slog-term-2.6.0/tests/term.rs010064400017500001750000000007331361435414500143410ustar0000000000000000extern crate slog; extern crate slog_async; extern crate slog_term; use slog::Drain; use slog_async::Async; fn main() { let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout()); let _drain = slog_term::FullFormat::new(decorator).build().fuse(); let decorator = slog_term::PlainDecorator::new(std::io::stdout()); let _drain = Async::new(slog_term::FullFormat::new(decorator).build().fuse()) .build() .fuse(); }