Struct quil::Context [] [src]

pub struct Context(_);

A logging context.

Contexts contain meta data for the association with logged messages.

Methods

impl Context
[src]

[src]

Creates a new context for use with a logger.

[src]

Sets a value within the context by a given key.

Arguments

  • key - A key for the value.
  • value - The value to add to the context.

Examples

Setting a value:

ctx.set("key", "value");

Clearing a value:

ctx.set("key", "");

[src]

Gets a value by key.

If the key does not exist then None will be returned.

Arguments

  • key - A key for the value.

Examples

ctx.set("key", "value");
assert_eq!(ctx.get("key").unwrap(), "value");

[src]

Create a new merged context from the context merge is called upon and a given context. The given context's values take precedence.

Arguments

  • context - A context that will be merged.

Examples

let context_a = context!{ a: "1", b: "2" };
let context_b = context!{ b: "3", c: "4" };

let merged_context = context_a.merge(context_b);

assert_eq!(merged_context.get("a").unwrap(), "1");
assert_eq!(merged_context.get("b").unwrap(), "3");
assert_eq!(merged_context.get("c").unwrap(), "4");

[src]

Returns an iterator to iterate through the data contained within the context.

[src]

Consumes the context returning an iterator to iterate through the data once contained within the context.

Trait Implementations

impl Debug for Context
[src]

[src]

Formats the value using the given formatter.

impl Clone for Context
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Display for Context
[src]

[src]

Formats the value using the given formatter. Read more