-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version with fortio logger (#2)
* initial version with fortio logger * adding threads/goroutines * record GOMAXPROCS * A bit more verbose log * the goroutine part can be abstracted/reused
- Loading branch information
Showing
3 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
# Small arg for overview testing | ||
# 150 calls to logger (3 go routines * 10 iterations * (4 invisible + 1 visible)) so with 3*40 of them not logged unless -loglevel debug is passed: | ||
ARGS:=-n 10 -e 4 -r 3 | ||
|
||
|
||
manual-check: | ||
@echo "--- Manual eyeball test, should have 10 log entries (out of 50 made) ---" | ||
go run . fortio $(ARGS) 2>&1 | jq -c | ||
@echo "--- Manual eyeball test, should have all 50 entries - in color and with goroutine just for fun ---" | ||
GOMAXPROCS=8 go run -race . fortio $(ARGS) -loglevel debug -logger-force-color=true -logger-goroutine=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"fortio.org/log" | ||
) | ||
|
||
func FortioLog1(id string, numLogged int64, numExtraNotLogged int) { | ||
// iterate numCalls time | ||
for i := int64(1); i <= numLogged; i++ { | ||
// Not optimized version - otherwise we can mutate the KeyVals | ||
log.S(log.Info, "A visible log entry with 3 attributes", | ||
log.Attr("iteration", i), | ||
log.Str("id", id), | ||
log.Str("logger", "fortio"), | ||
) | ||
for j := 1; j <= numExtraNotLogged; j++ { | ||
// Not optimized version - otherwise we'd check | ||
// if log.LogDebug() {...} | ||
log.S(log.Debug, "Not visible entry with 4 attributes", | ||
log.Str("id", id), | ||
log.Attr("iteration", i), | ||
log.Attr("sub-iteration", j), | ||
log.Str("logger", "fortio"), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters