# LogChannel

<a id="logchannel"></a>

# LogChannel

```cpp
#include <icy/logger.h>

class LogChannel
```

[Defined in src/base/include/icy/logger.h:384](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L384)

> **Subclassed by:** [`ConsoleChannel`](https://auscaster.com/icey/docs/api-reference/icy-ConsoleChannel.md#consolechannel), [`FileChannel`](https://auscaster.com/icey/docs/api-reference/icy-FileChannel.md#filechannel), [`RotatingFileChannel`](https://auscaster.com/icey/docs/api-reference/icy-RotatingFileChannel.md#rotatingfilechannel)

Named log output channel with configurable severity level and formatting.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`LogChannel`](#logchannel-1)  |  |
|  | [`~LogChannel`](#logchannel-2) `virtual` | Defaulted destructor. |
| `void` | [`write`](#write-5) `virtual` | Writes a log stream entry to this channel. |
| `void` | [`write`](#write-6) `virtual` | Writes a plain message to this channel. |
| `void` | [`format`](#format-4) `virtual` | Formats a log stream entry into the given output stream. |
| `std::string` | [`name`](#name-1) `const` `inline` | Returns the channel name. |
| [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level) | [`level`](#level-1) `const` `inline` | Returns the minimum severity level. |
| `std::string` | [`timeFormat`](#timeformat) `const` `inline` | Returns the timestamp format string. |
| `void` | [`setLevel`](#setlevel) `inline` | Sets the minimum severity level. |
| `void` | [`setTimeFormat`](#settimeformat) `inline` | Sets the timestamp format string. |
| `void` | [`setFilter`](#setfilter) `inline` | Sets a realm filter; only messages whose realm matches are written. |

---

<a id="logchannel-1"></a>

### LogChannel

```cpp
LogChannel(std::string name, Level level = Level::Debug, std::string timeFormat = "%H:%M:%S")
```

[Defined in src/base/include/icy/logger.h:390](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L390)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | `std::string` | Unique channel name. |
| `level` | [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level) | Minimum severity level; messages below this level are dropped. |
| `timeFormat` | `std::string` | strftime-compatible format string for timestamps. |

---

<a id="logchannel-2"></a>

### ~LogChannel

`virtual`

```cpp
virtual ~LogChannel() = default
```

[Defined in src/base/include/icy/logger.h:392](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L392)

Defaulted destructor.

---

<a id="write-5"></a>

### write

`virtual`

```cpp
virtual void write(const LogStream & stream)
```

[Defined in src/base/include/icy/logger.h:396](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L396)

Writes a log stream entry to this channel.

#### Reimplemented by

- [`ConsoleChannel::write`](https://auscaster.com/icey/docs/api-reference/icy-ConsoleChannel.md#write-1)
- [`FileChannel::write`](https://auscaster.com/icey/docs/api-reference/icy-FileChannel.md#write-2)
- [`RotatingFileChannel::write`](https://auscaster.com/icey/docs/api-reference/icy-RotatingFileChannel.md#write-15)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `stream` | const [`LogStream`](https://auscaster.com/icey/docs/api-reference/icy-LogStream.md#logstream) & | The log stream to write. |

---

<a id="write-6"></a>

### write

`virtual`

```cpp
virtual void write(std::string message, Level level = Level::Debug, std::string realm = "")
```

[Defined in src/base/include/icy/logger.h:402](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L402)

Writes a plain message to this channel.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `message` | `std::string` | Log message text. |
| `level` | [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level) | Severity level for the message. |
| `realm` | `std::string` | Optional source realm (e.g. file or class name). |

---

<a id="format-4"></a>

### format

`virtual`

```cpp
virtual void format(const LogStream & stream, std::ostream & ost)
```

[Defined in src/base/include/icy/logger.h:408](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L408)

Formats a log stream entry into the given output stream.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `stream` | const [`LogStream`](https://auscaster.com/icey/docs/api-reference/icy-LogStream.md#logstream) & | The log stream to format. |
| `ost` | `std::ostream &` | The output stream to write the formatted message into. |

---

<a id="name-1"></a>

### name

`const` `inline`

```cpp
inline std::string name() const
```

[Defined in src/base/include/icy/logger.h:411](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L411)

Returns the channel name.

---

<a id="level-1"></a>

### level

`const` `inline`

```cpp
inline Level level() const
```

[Defined in src/base/include/icy/logger.h:414](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L414)

Returns the minimum severity level.

---

<a id="timeformat"></a>

### timeFormat

`const` `inline`

```cpp
inline std::string timeFormat() const
```

[Defined in src/base/include/icy/logger.h:417](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L417)

Returns the timestamp format string.

---

<a id="setlevel"></a>

### setLevel

`inline`

```cpp
inline void setLevel(Level level)
```

[Defined in src/base/include/icy/logger.h:421](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L421)

Sets the minimum severity level.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `level` | [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level) | Messages below this level are dropped. |

---

<a id="settimeformat"></a>

### setTimeFormat

`inline`

```cpp
inline void setTimeFormat(std::string format)
```

[Defined in src/base/include/icy/logger.h:429](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L429)

Sets the timestamp format string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `format` | `std::string` | strftime-compatible format string. |

---

<a id="setfilter"></a>

### setFilter

`inline`

```cpp
inline void setFilter(std::string filter)
```

[Defined in src/base/include/icy/logger.h:433](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L433)

Sets a realm filter; only messages whose realm matches are written.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `filter` | `std::string` | Realm substring or pattern to match against. |

## Protected Attributes

| Return | Name | Description |
|--------|------|-------------|
| `std::string` | [`_name`](#_name)  |  |
| [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level) | [`_level`](#_level)  |  |
| `std::string` | [`_timeFormat`](#_timeformat)  |  |
| `std::string` | [`_filter`](#_filter)  |  |

---

<a id="_name"></a>

### _name

```cpp
std::string _name
```

[Defined in src/base/include/icy/logger.h:436](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L436)

---

<a id="_level"></a>

### _level

```cpp
Level _level
```

Type: [`Level`](https://auscaster.com/icey/docs/api-reference/base.md#level)

[Defined in src/base/include/icy/logger.h:437](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L437)

---

<a id="_timeformat"></a>

### _timeFormat

```cpp
std::string _timeFormat
```

[Defined in src/base/include/icy/logger.h:438](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L438)

---

<a id="_filter"></a>

### _filter

```cpp
std::string _filter
```

[Defined in src/base/include/icy/logger.h:439](https://github.com/auscaster/icey/blob/main/src/base/include/icy/logger.h#L439)
