---
title: llarp::LogContext

---

# llarp::LogContext





## Public Types

|                | Name           |
| -------------- | -------------- |
| using std::function< void(void)> | **[IOFunc_t](Classes/structllarp_1_1LogContext.md#using-iofunc-t)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[LogContext](Classes/structllarp_1_1LogContext.md#function-logcontext)**() |
| void | **[DropToRuntimeLevel](Classes/structllarp_1_1LogContext.md#function-droptoruntimelevel)**() |
| void | **[RevertRuntimeLevel](Classes/structllarp_1_1LogContext.md#function-revertruntimelevel)**() |
| void | **[ImmediateFlush](Classes/structllarp_1_1LogContext.md#function-immediateflush)**()<br>A blocking call that will not return until any existing log functions have flushed.  |
| void | **[Initialize](Classes/structllarp_1_1LogContext.md#function-initialize)**(LogLevel level, LogType type, const std::string & file, const std::string & nickname, std::function< void(IOFunc_t)> io)<br>Initialize the logging system.  |
| [LogContext](Classes/structllarp_1_1LogContext.md) & | **[Instance](Classes/structllarp_1_1LogContext.md#function-instance)**() |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| LogLevel | **[curLevel](Classes/structllarp_1_1LogContext.md#variable-curlevel)**  |
| LogLevel | **[startupLevel](Classes/structllarp_1_1LogContext.md#variable-startuplevel)**  |
| LogLevel | **[runtimeLevel](Classes/structllarp_1_1LogContext.md#variable-runtimelevel)**  |
| ILogStream_ptr | **[logStream](Classes/structllarp_1_1LogContext.md#variable-logstream)**  |
| std::string | **[nodeName](Classes/structllarp_1_1LogContext.md#variable-nodename)**  |

## Public Types Documentation

### using IOFunc_t

```cpp
using llarp::LogContext::IOFunc_t =  std::function<void(void)>;
```


## Public Functions Documentation

### function LogContext

```cpp
LogContext()
```


### function DropToRuntimeLevel

```cpp
void DropToRuntimeLevel()
```


### function RevertRuntimeLevel

```cpp
void RevertRuntimeLevel()
```


### function ImmediateFlush

```cpp
void ImmediateFlush()
```

A blocking call that will not return until any existing log functions have flushed. 

Should only be called in rare circumstances, such as when the program is about to exit. 


### function Initialize

```cpp
void Initialize(
    LogLevel level,
    LogType type,
    const std::string & file,
    const std::string & nickname,
    std::function< void(IOFunc_t)> io
)
```

Initialize the logging system. 

**Parameters**: 

  * **level** is the new log level (below which log statements will be ignored) 
  * **type** is the type of logger to set up 
  * **file** is the file to log to (relevant for types File and Json) 
  * **nickname** is a tag to add to each log statement 
  * **io** is a callable that queues work that does io, async 


### function Instance

```cpp
static LogContext & Instance()
```


## Public Attributes Documentation

### variable curLevel

```cpp
LogLevel curLevel = eLogInfo;
```


### variable startupLevel

```cpp
LogLevel startupLevel = eLogInfo;
```


### variable runtimeLevel

```cpp
LogLevel runtimeLevel = eLogWarn;
```


### variable logStream

```cpp
ILogStream_ptr logStream;
```


### variable nodeName

```cpp
std::string nodeName = "lokinet";
```


-------------------------------

Updated on 2022-05-20 at 15:34:05 +0000