MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / Add

Method Add

internal/users/userlog.go:23–56  ·  view source on GitHub ↗
(cat string, message string)

Source from the content-addressed store, hash-verified

21type UserLog []UserLogEntry
22
23func (ul *UserLog) Add(cat string, message string) {
24
25 if LogMinAllocation < 1 { // disables log if <1
26 return
27 }
28
29 if len(*ul) == cap(*ul) {
30
31 if cap(*ul) < LogMaxAllocation {
32
33 newUL := make(UserLog, len(*ul), cap(*ul)+LogMinAllocation)
34 copy(newUL, *ul)
35 *ul = newUL
36
37 } else {
38
39 newUL := make(UserLog, len(*ul)-1, LogMaxAllocation)
40 copy(newUL, (*ul)[1:])
41 *ul = newUL
42
43 }
44
45 }
46
47 newEntry := UserLogEntry{
48 Category: cat,
49 WhenTime: time.Now(),
50 WhenRound: util.GetRoundCount(),
51 What: message,
52 }
53
54 *ul = append(*ul, newEntry)
55
56}
57
58func (ul *UserLog) Items(yield func(UserLogEntry) bool) {
59 for _, v := range *ul {

Calls 1

GetRoundCountFunction · 0.92