RIT VEXU Core API
Loading...
Searching...
No Matches
logger.h
1#pragma once
2
3#include "vex.h"
4#include <cstdarg>
5#include <cstdio>
6#include <string>
7
9enum LogLevel { DEBUG, NOTICE, WARNING, ERROR, CRITICAL, TIME };
10
12class Logger {
13private:
14 const std::string filename;
15 vex::brain::sdcard sd;
16 void write_level(LogLevel l);
17
18public:
20 static constexpr int MAX_FORMAT_LEN = 512;
23 explicit Logger(const std::string &filename);
24
26 Logger(const Logger &l) = delete;
28 Logger &operator=(const Logger &l) = delete;
29
32 void Log(const std::string &s);
33
37 void Log(LogLevel level, const std::string &s);
38
41 void Logln(const std::string &s);
42
46 void Logln(LogLevel level, const std::string &s);
47
51 void Logf(const char *fmt, ...);
52
57 void Logf(LogLevel level, const char *fmt, ...);
58};
Class to simplify writing to files.
Definition logger.h:12
Logger & operator=(const Logger &l)=delete
copying not allowed
void Logf(const char *fmt,...)
Write a formatted string to the log.
Definition logger.cpp:51
void Log(const std::string &s)
Write a string to the log.
Definition logger.cpp:35
Logger(const std::string &filename)
Create a logger that will save to a file.
Definition logger.cpp:33
void Logln(const std::string &s)
Write a string and newline to the log.
Definition logger.cpp:41
static constexpr int MAX_FORMAT_LEN
maximum size for a string to be before it's written
Definition logger.h:20
Logger(const Logger &l)=delete
copying not allowed