---
title: llarp::FileLogStream
summary: flushable file based log stream 

---

# llarp::FileLogStream



flushable file based log stream 


`#include <file_logger.hpp>`

Inherits from [llarp::ILogStream](Classes/structllarp_1_1ILogStream.md)

## Public Types

|                | Name           |
| -------------- | -------------- |
| using std::function< void(void)> | **[Work_t](Classes/structllarp_1_1FileLogStream.md#using-work-t)**  |
| using [thread::Queue](Classes/classllarp_1_1thread_1_1Queue.md)< std::string > | **[Lines_t](Classes/structllarp_1_1FileLogStream.md#using-lines-t)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[FileLogStream](Classes/structllarp_1_1FileLogStream.md#function-filelogstream)**(std::function< void(Work_t)> io, FILE * f, llarp_time_t flushInterval, bool closefile =true) |
| | **[~FileLogStream](Classes/structllarp_1_1FileLogStream.md#function-~filelogstream)**() override |
| virtual void | **[PreLog](Classes/structllarp_1_1FileLogStream.md#function-prelog)**(std::stringstream & out, LogLevel lvl, std::string_view filename, int lineno, const std::string & nodename) const override |
| virtual void | **[Print](Classes/structllarp_1_1FileLogStream.md#function-print)**(LogLevel , std::string_view filename, const std::string & msg) override |
| virtual void | **[Tick](Classes/structllarp_1_1FileLogStream.md#function-tick)**(llarp_time_t now) override<br>called every end of event loop tick  |
| virtual void | **[PostLog](Classes/structllarp_1_1FileLogStream.md#function-postlog)**(std::stringstream & ) const override |
| virtual void | **[AppendLog](Classes/structllarp_1_1FileLogStream.md#function-appendlog)**(LogLevel lvl, std::string_view filename, int lineno, const std::string & nodename, const std::string msg) override |
| virtual void | **[ImmediateFlush](Classes/structllarp_1_1FileLogStream.md#function-immediateflush)**() override<br>A blocking call to flush to disk. Should only be called in rare circumstances.  |

## Protected Attributes

|                | Name           |
| -------------- | -------------- |
| [Lines_t](Classes/classllarp_1_1thread_1_1Queue.md) | **[m_Lines](Classes/structllarp_1_1FileLogStream.md#variable-m-lines)**  |

## Additional inherited members

**Public Functions inherited from [llarp::ILogStream](Classes/structllarp_1_1ILogStream.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~ILogStream](Classes/structllarp_1_1ILogStream.md#function-~ilogstream)**() =default |


## Public Types Documentation

### using Work_t

```cpp
using llarp::FileLogStream::Work_t =  std::function<void(void)>;
```


### using Lines_t

```cpp
using llarp::FileLogStream::Lines_t =  thread::Queue<std::string>;
```


## Public Functions Documentation

### function FileLogStream

```cpp
FileLogStream(
    std::function< void(Work_t)> io,
    FILE * f,
    llarp_time_t flushInterval,
    bool closefile =true
)
```


### function ~FileLogStream

```cpp
~FileLogStream() override
```


### function PreLog

```cpp
virtual void PreLog(
    std::stringstream & out,
    LogLevel lvl,
    std::string_view filename,
    int lineno,
    const std::string & nodename
) const override
```


**Reimplements**: [llarp::ILogStream::PreLog](Classes/structllarp_1_1ILogStream.md#function-prelog)


### function Print

```cpp
virtual void Print(
    LogLevel ,
    std::string_view filename,
    const std::string & msg
) override
```


**Reimplements**: [llarp::ILogStream::Print](Classes/structllarp_1_1ILogStream.md#function-print)


### function Tick

```cpp
virtual void Tick(
    llarp_time_t now
) override
```

called every end of event loop tick 

**Reimplements**: [llarp::ILogStream::Tick](Classes/structllarp_1_1ILogStream.md#function-tick)


### function PostLog

```cpp
inline virtual void PostLog(
    std::stringstream & 
) const override
```


**Reimplements**: [llarp::ILogStream::PostLog](Classes/structllarp_1_1ILogStream.md#function-postlog)


### function AppendLog

```cpp
virtual void AppendLog(
    LogLevel lvl,
    std::string_view filename,
    int lineno,
    const std::string & nodename,
    const std::string msg
) override
```


**Reimplements**: [llarp::ILogStream::AppendLog](Classes/structllarp_1_1ILogStream.md#function-appendlog)


### function ImmediateFlush

```cpp
virtual void ImmediateFlush() override
```

A blocking call to flush to disk. Should only be called in rare circumstances. 

**Reimplements**: [llarp::ILogStream::ImmediateFlush](Classes/structllarp_1_1ILogStream.md#function-immediateflush)


## Protected Attributes Documentation

### variable m_Lines

```cpp
Lines_t m_Lines;
```


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

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