-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHexaLog.cpp
More file actions
63 lines (59 loc) · 1.38 KB
/
HexaLog.cpp
File metadata and controls
63 lines (59 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "HexaLog.h"
void LogSettings (byte Level, byte Section)
{
LogLevel = Level;
LogSection = Section;
}
void Log (String Message, byte Level, byte Section)
{
if (Level <= LogLevel && Level > 0 || LogSection == Section && Section > 0)
{
Serial.print (LeadingSpaces (millis ()));
Serial.print (F ("ms [S "));
Serial.print (LeadingSpaces (Section));
Serial.print (F (" --> "));
switch (Level)
{
case 1: Serial.print (F (" Error"));
break;;
case 2: Serial.print (F ("Warning"));
break;;
case 3: Serial.print (F (" Info"));
break;;
case 4: Serial.print (F (" Debug"));
break;;
default: Serial.print (F (" ???"));
break;;
}
Serial.print (F ("]: "));
Serial.println (Message);
}
}
String LeadingSpaces (byte Number)
{
String X;
if (Number < 100 && Number >= 10)
X += " ";
else if (Number < 10)
X += " ";
X += String (Number);
return X;
}
String LeadingSpaces (unsigned long Number)
{
String X;
if (Number < 1000000 && Number >= 100000)
X += " ";
else if (Number < 100000 && Number >= 10000)
X += " ";
else if (Number < 10000 && Number >= 1000)
X += " ";
else if (Number < 1000 && Number >= 100)
X += " ";
else if (Number < 100 && Number >= 10)
X += " ";
else if (Number < 10)
X += " ";
X += String (Number);
return X;
}