# Logger

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/logging/struct-logger/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct Logger
```

Logs events.

The sink is process-wide and therefore has to be thread-safe. In
addition, a thread can install a sink of its own with
`set_thread_sink`; it takes precedence over the
process-wide sink on that thread, does not have to be thread-safe, and is
what unit tests (which run in parallel) use to observe log events.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L24)

## Members

- [`sink`](#function-sink)
- [`set_sink`](#function-set_sink)
- [`thread_sink`](#function-thread_sink)
- [`set_thread_sink`](#function-set_thread_sink)
- [`is_enabled`](#function-is_enabled)
- [`try_get`](#function-try_get)

<a id="function-sink"></a>

### sink

```rust
fn sink() -> Option<Arc<dyn ILogSink + Send + Sync>>
```

Gets the application-defined sink for logging.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L28)

<a id="function-set_sink"></a>

### set_sink

```rust
fn set_sink(sink: Option<Arc<dyn ILogSink + Send + Sync>>)
```

Sets the application-defined sink for logging.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L36)

<a id="function-thread_sink"></a>

### thread_sink

```rust
fn thread_sink() -> Option<Rc<dyn ILogSink>>
```

Gets the sink of the calling thread, if it has one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L46)

<a id="function-set_thread_sink"></a>

### set_thread_sink

```rust
fn set_thread_sink(sink: Option<Rc<dyn ILogSink>>) -> Option<Rc<dyn ILogSink>>
```

Sets a sink that receives the events logged on the calling thread
instead of the process-wide sink. Returns the previous thread sink.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L55)

<a id="function-is_enabled"></a>

### is_enabled

```rust
fn is_enabled(level: LogEventLevel, area: &str) -> bool
```

Checks if given log level is enabled.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L68)

<a id="function-try_get"></a>

### try_get

```rust
fn try_get(level: LogEventLevel, area: &'static str) -> Option<ParametrizedLogger>
```

Returns a parametrized logging sink if given log level is enabled.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/logging/logger.rs#L76)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
