Skip to content

daisy::Logger

Module: LIBDAISY / HUMAN_INTERFACE / LOGGING

Interface for simple USB logging. More...

#include <logger.h>

Protected Types

Name
enum LoggerConsts

Public Functions

Name
Logger()
void Print(const char * format, ... )
void PrintLine(const char * format, ... )
void StartLog(bool wait_for_pc =false)
void PrintV(const char * format, va_list va)
void PrintLineV(const char * format, va_list va)

Protected Functions

Name
void TransmitSync(const void * buffer, size_t bytes)
void TransmitBuf()
void AppendNewLine()
constexpr size_t NewLineSeqLength()

Protected Attributes

Name
char[128] tx_buff_
size_t tx_ptr_
size_t pc_sync_
LoggerImpl< dest > impl_

Detailed Description

template <LoggerDestination dest =LOGGER_INTERNAL>
class daisy::Logger;

Interface for simple USB logging.

Author: Alexander Petrov-Savchenko ([email protected])

Date: November 2020

Simple Example: ```cpp

include "daisy_seed.h"

using namespace daisy;

DaisySeed hw;

int main(void) { // Initialize the Daisy Seed hw.Init(); // Start the log, and wait for connection hw.StartLog(true); // Print "Hello World" to the Serial Monitor hw.PrintLine("Hello World!"); while(1) {} }

_Filename: SerialPrint.cpp_

## Protected Types Documentation

### enum LoggerConsts

| Enumerator | Value | Description |
| ---------- | ----- | ----------- |
| LOGGER_SYNC_OUT | 0|   |
| LOGGER_SYNC_IN | 2|  successfully transmit this many packets before switching to blocking transfers  |




Internal constants 


## Public Functions Documentation

### function Logger

```cpp
inline Logger()

Object constructor


function Print

static void Print(
    const char * format,
    ... 
)

Print formatted string


function PrintLine

static void PrintLine(
    const char * format,
    ... 
)

Print formatted string appending line termination sequence


function StartLog

static void StartLog(
    bool wait_for_pc =false
)

Parameters:

  • wait_for_pc block until remote terminal is ready

Start the logging session.


function PrintV

static void PrintV(
    const char * format,
    va_list va
)

Variadic argument variant of Print()


function PrintLineV

static void PrintLineV(
    const char * format,
    va_list va
)

Variadic argument variant of PrintLine()


Protected Functions Documentation

function TransmitSync

static inline void TransmitSync(
    const void * buffer,
    size_t bytes
)

Blocking wrapper for Transmit()

function TransmitBuf

static void TransmitBuf()

Transfer accumulated data

function AppendNewLine

static void AppendNewLine()

Trim control characters and append clean newline sequence, if there's room in the buffer

function NewLineSeqLength

static inline constexpr size_t NewLineSeqLength()

Constexpr function equivalent of strlen(LOGGER_NEWLINE)

< custom newline character sequence

Protected Attributes Documentation

variable tx_buff_

static char[128] tx_buff_;

member variables buffer for log data

this needs to remain in SRAM to support startup-time printouts

variable tx_ptr_

static size_t tx_ptr_ = 0;

current position in the buffer

variable pc_sync_

static size_t pc_sync_ = LOGGER_SYNC_OUT;

terminal synchronization state

start with non-blocking transfers to support startup-time printouts

variable impl_

static LoggerImpl< dest > impl_;

underlying trasnfer implementation


Updated on 2024-01-03 at 19:41:01 +0000