Skip to content

Commit 4781feb

Browse files
authored
Merge pull request arduino#205 from arduino/humanlevels
Report the message levels on the human logger
2 parents eae075b + 2dee1c3 commit 4781feb

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This tool generates function prototypes and gathers library paths, providing `gc
3333

3434
* `-core-api-version`: Optional, defaults to "10600". The version of the Arduino IDE which is using this tool.
3535

36-
* `-logger`: Optional, can be "human" or "machine". Defaults to "human". If "machine", messages emitted will be in a format which the Arduino IDE understands and that it uses for I18N.
36+
* `-logger`: Optional, can be "human", "humantags" or "machine". Defaults to "human". If "humantags" the messages are qualified with a prefix that indicates their level (info, debug, error). If "machine", messages emitted will be in a format which the Arduino IDE understands and that it uses for I18N.
3737

3838
* `-version`: if specified, prints version and exits.
3939

src/arduino.cc/arduino-builder/main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const FLAG_WARNINGS_MORE = "more"
7575
const FLAG_WARNINGS_ALL = "all"
7676
const FLAG_LOGGER = "logger"
7777
const FLAG_LOGGER_HUMAN = "human"
78+
const FLAG_LOGGER_HUMANTAGS = "humantags"
7879
const FLAG_LOGGER_MACHINE = "machine"
7980
const FLAG_VERSION = "version"
8081
const FLAG_VID_PID = "vid-pid"
@@ -155,7 +156,7 @@ func init() {
155156
quietFlag = flag.Bool(FLAG_QUIET, false, "if 'true' doesn't print any warnings or progress or whatever")
156157
debugLevelFlag = flag.Int(FLAG_DEBUG_LEVEL, builder.DEFAULT_DEBUG_LEVEL, "Turns on debugging messages. The higher, the chattier")
157158
warningsLevelFlag = flag.String(FLAG_WARNINGS, "", "Sets warnings level. Available values are '"+FLAG_WARNINGS_NONE+"', '"+FLAG_WARNINGS_DEFAULT+"', '"+FLAG_WARNINGS_MORE+"' and '"+FLAG_WARNINGS_ALL+"'")
158-
loggerFlag = flag.String(FLAG_LOGGER, FLAG_LOGGER_HUMAN, "Sets type of logger. Available values are '"+FLAG_LOGGER_HUMAN+"', '"+FLAG_LOGGER_MACHINE+"'")
159+
loggerFlag = flag.String(FLAG_LOGGER, FLAG_LOGGER_HUMAN, "Sets type of logger. Available values are '"+FLAG_LOGGER_HUMAN+"', '"+FLAG_LOGGER_HUMANTAGS+"', '"+FLAG_LOGGER_MACHINE+"'")
159160
versionFlag = flag.Bool(FLAG_VERSION, false, "prints version and exits")
160161
vidPidFlag = flag.String(FLAG_VID_PID, "", "specify to use vid/pid specific build properties, as defined in boards.txt")
161162
}
@@ -321,6 +322,8 @@ func main() {
321322
ctx.SetLogger(i18n.NoopLogger{})
322323
} else if *loggerFlag == FLAG_LOGGER_MACHINE {
323324
ctx.SetLogger(i18n.MachineLogger{})
325+
} else if *loggerFlag == FLAG_LOGGER_HUMANTAGS {
326+
ctx.SetLogger(i18n.HumanTagsLogger{})
324327
} else {
325328
ctx.SetLogger(i18n.HumanLogger{})
326329
}

src/arduino.cc/builder/i18n/i18n.go

+15
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ func (s NoopLogger) Name() string {
5858
return "noop"
5959
}
6060

61+
type HumanTagsLogger struct{}
62+
63+
func (s HumanTagsLogger) Fprintln(w io.Writer, level string, format string, a ...interface{}) {
64+
format = "[" + level + "] " + format
65+
fmt.Fprintln(w, Format(format, a...))
66+
}
67+
68+
func (s HumanTagsLogger) Println(level string, format string, a ...interface{}) {
69+
s.Fprintln(os.Stdout, level, format, a...)
70+
}
71+
72+
func (s HumanTagsLogger) Name() string {
73+
return "humantags"
74+
}
75+
6176
type HumanLogger struct{}
6277

6378
func (s HumanLogger) Fprintln(w io.Writer, level string, format string, a ...interface{}) {

0 commit comments

Comments
 (0)