GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — added SetTimestamp() · projectdiscovery/gologger@d1c3291

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • gologger.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎gologger.go‎

Copy file name to clipboardExpand all lines: gologger.go
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
}
2323
// DefaultLogger is the default logging instance
2424
DefaultLogger *Logger
25+
addTimestamp bool
2526
)
2627

2728
func init() {
@@ -94,6 +95,12 @@ func (e *Event) TimeStamp() *Event {
9495
return e
9596
}
9697

98+
// SetTimestamp sets a global flag indicating whether or not to add timestamps to debug logs.
99+
// If the flag is set to true, timestamps will be added to debug logs.
100+
func SetTimestamp(timestamp bool) {
101+
addTimestamp = timestamp
102+
}
103+
97104
// Str adds a string metadata item to the log
98105
func (e *Event) Str(key, value string) *Event {
99106
e.metadata[key] = value
@@ -167,6 +174,11 @@ func Debug() *Event {
167174
metadata: make(map[string]string),
168175
}
169176
event.metadata["label"] = labels[level]
177+
178+
if addTimestamp {
179+
event.TimeStamp()
180+
}
181+
170182
return event
171183
}
172184

0 commit comments

Comments
0 (0)
You are visitor 01402622 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.