Giter Site home page Giter Site logo

embeddedartistry / arduino-logger Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 10.0 264 KB

Flexible logging library for the Arduino SDK, allowing the same logging interface to be used with multiple outputs.

License: MIT License

C++ 97.91% Makefile 0.88% Meson 0.71% Groovy 0.50%
arduino arduino-library arduino-mega logging logging-framework logging-library teensy teensy36 teensyduino

arduino-logger's People

Contributors

phillipjohnston avatar rw-schumann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

arduino-logger's Issues

Rebrand library

From Kelley:

Consider generalizing the project name for broader C++ use. The library is generic but just happens to support Arduino. (and doesn't use streams)

Create a log disable strategy

What if a user wanted to compile-out all logging without relying on the macros? In this case, I could see using a "log disable" strategy of some sort.

We could make a class that doesn't perform any logging. With it, we can see how effective such a strategy would be. Do calls eventually get compiled out because they are no-ops? Does the class itself?

Redesign to eliminate macros

Feedback from Kelley:

It's not obvious that it needs to be singleton. Might be useful to have multiple loggers at some point. If desirable to only have one instance, users can enforce that by convention. (just instantiate one)

My response:

Agreed with you here. There's currently nothing that prevents multiple loggers from being declared and used, but the interface won't be friendly. That will be improved per your suggestion.
The original goal was to abstract things so users didn't have to worry about properly passing around a logger instance to multiple files/modules. I originally had a client misuse some logging code by declaring multiple loggers and being surprised that some messages were missing from the buffer.
I'll think about how to modify the design so that it works conveniently if you want a global logger instance, and still works well if you want to create multiple loggers.

Expand rotational SD logger support

  • Add an option for placing a cap on log file size
  • Rotate log files when they are full
  • Allow user to configure the number of log files to rotate between

Add a TRACE macro

I said:

I remembered why I went the macro route in my original code. It wasn't because I wanted to hide the inst(), that was just a bonus. The real reason for using macros is that there's no other way to get file, line number, or function information unless you use the preprocessor. That will change in C++20... but we can't use that.

From Kelley:

Wondering if there could be a TRACE(...) macro that prints the file, line, etc.

Log::error("null pointer. %s\n", TRACE());

Rebrand Library OR Extract non-Arduino logging core into another library

I had this thought yesterday, because the core logic I used is general C++ and not tied to Arduino. I've created a repo for a C++ embedded logger to house some of the core code and generalize it. The goal is that the core library would live there, and the arduino-logging library would submodule it, provide arduino-specific logging strategies, examples, and support the library organizational structure.

There's a two problems I'm thinking about ways to address:

I like a more organized project structure, and Arduino enforces a top-level file set for libraries, or else things aren't properly discovered
I think I can solve this with wrapper headers, but I ran into some include problems earlier today, so I need to work out the kinks
There are C++14/C++17 features that I use in the original library that had to be stripped out for the Arduino ecosystem, I'm not sure how I want to manage that dichotomy

Unable to clone project

hi i try to clone project to my local but getting error in multiple files one example as below:

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:embeddedartistry/cppcheck-rules.git' into submodule path 'C:/arduino-logger/build/analysis/cppcheck/cppcheck-rules' failed
Failed to clone 'analysis/cppcheck/cppcheck-rules'. Retry scheduled
Cloning into 'C:/arduino-logger/build/analysis/vale/vale-styleguide'...
fatal: Could not read from remote repository.

thank you

Add Meson Documentation

I need to add documentation on using the meson build system + using this project as a meson subproject.

Improve Checks for Flushing and Overrun

Right now, we do this check per-character, which is quite inefficient:

	virtual void log_add_char_to_buffer(char c)
	{
		if(auto_flush() && (internal_size() == internal_capacity()))
		{
			flush();
		}
		else if (internal_size() == internal_capacity())
		{
			overrun_occurred_ = true;
		}

		log_putc(c);
	}

Ideally we'd check for the full contents of the string to be added to the log, splitting earlier than the character level. Perhaps this occurs in print()?

Timestamp support

We want milliseconds from boot.

How can we take in a timestamp without a) requiring a system clock, and b) using the millis() function directly?

Also, how can we generalize the format for possibility of HH::MM::SS vs millis from boot?

Test with Arduino 1.5

Request from Kelley:

Please test a bit with Arduino 1.5 version soon to see if it supports the lang features you're using.. One product wuses 1.5 and another uses 1.6/1.8 version. If not, and hard to adapt, I vote continuing with 1.6/1/8 version, and we can get that working and ponder 1.5 later.

Improve compile-time Filtering

  • Improve support for compile-time filtering with macros, so users don't need a global instance
  • Explore compile-time filtering using templates

Error : 'SdFs' has not been declared

I don't know much cpp, and relatively new to Arduino ecosystem. While trying to use the example, I get following error.

I installed, arduino-printf, arduino-logger and tried with https://github.com/greiman/SdFat-beta and https://github.com/greiman/SdFs (which say deprecated). Still same error.

Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:76:13: error: 'SdFs' has not been declared
  void begin(SdFs& sd_inst)
             ^~~~
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:186:2: error: 'SdFs' does not name a type; did you mean 'SdFile'?
  SdFs* fs_;
  ^~~~
  SdFile
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:188:2: error: 'FsFile' does not name a type; did you mean 'SDFile'?
  FsFile file_;
  ^~~~~~
  SDFile
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h: In member function 'virtual size_t AVRSDRotationalLogger::size() const':
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:39:10: error: 'file_' was not declared in this scope
   return file_.size();
          ^~~~~
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:39:10: note: suggested alternative: 'fileno'
   return file_.size();
          ^~~~~
          fileno
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h: In member function 'virtual size_t AVRSDRotationalLogger::capacity() const':
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:45:10: error: 'fs_' was not declared in this scope
   return fs_ ? fs_->card()->sectorCount() << 9 : 0;
          ^~~
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:45:10: note: suggested alternative: 'fbs_t'
   return fs_ ? fs_->card()->sectorCount() << 9 : 0;
          ^~~
          fbs_t
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h: In member function 'virtual void AVRSDRotationalLogger::flush()':
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:50:7: error: 'file_' was not declared in this scope
   if(!file_.open(filename_, O_WRITE | O_APPEND))
       ^~~~~
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:50:7: note: suggested alternative: 'fileno'
   if(!file_.open(filename_, O_WRITE | O_APPEND))
       ^~~~~
       fileno
/Users/bsr/Documents/Arduino/libraries/arduino-logger-master/src/AVRSDRotationalLogger.h:55:11: error: 'file_' was not declared in this scope
   int r = file_.write(buffer_, counter);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.