Skip to content

This library is used to implement log output on the Arduino platform.

Notifications You must be signed in to change notification settings

Ning-Qing/ArduinoLogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArdunioLog

This library is used to implement log output on the Arduino platform.Providing an output classification, positioning statement, formatted output function, the output of free memory.

Use

#include <Logger.h>

#define LOG_LEVEL LOG_DEBUG

void setup()
{
  Serial.begin(9600);
  while (!Serial)
    continue;
  Serial.println(F("Run..."));
  Logger log(&Serial);
  log.setPrefix("[log]");
  log.debug("Info %d",5);
  log.debug("Info %c",'1');
  log.error("Info %f",9.9);
  log.error("Info %t",true);
  log.info("Log library by NingQing,time: %s, version:%f \n","2021-5-7",1.0);
// output
//  Run...
// [log] Info 5 file: src\main.cpp line: 13 level: D
// [log] Info 1 file: src\main.cpp line: 14 level: D
// [log] Info 9.90 file: src\main.cpp line: 15 level: E
// [log] Info true file: src\main.cpp line: 16 level: E
// Log library by NingQing,time: 2021-5-7, version:1.00  
}

void loop()
{
  // put your main code here, to run repeatedly:
}

Controllable output

Output achieved by modifying the log level grade.

#define LOG_LEVEL LOG_OFF       // no output
#define LOG_LEVEL LOG_DEBUG     // can output: debug error info
#define LOG_LEVEL LOG_TEST      // can output: error info
#define LOG_LEVEL LOG_RUN       // can output: error

Bind output object

Logger can be bound to class objects that inherit Print to achieve output

Logger log(&Serial);

Features

Formatted output

  • %s string (char*)
  • %c char
  • %d int
  • %f double
  • %t boole

Prompt information

  • Execute the statement where the source file name and line number
  • Free memory(Bit)

About

This library is used to implement log output on the Arduino platform.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages