Skip to content

Commit 6e87ac5

Browse files
author
vals
committed
Update doc
1 parent c329365 commit 6e87ac5

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

log.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,40 @@ var (
1313
mu sync.Mutex
1414
)
1515

16-
// New returns a new Logger object. We can optionally provide one or more
17-
// prefixes that will be prepended to each log message. If multiple prefixes
18-
// are provided, they will be joined with hyphens. Additionally, prefixes
19-
// are stripped of leading and trailing whitespace characters.
16+
// New returns a new Logger object with optional prefixes for log messages.
17+
// If one or more prefixes are provided, they will be concatenated with
18+
// hyphens and prepended to each log message. Leading and trailing whitespace
19+
// characters are stripped from each prefix before concatenation.
2020
//
2121
// Example usage:
2222
//
23-
// // The simplest use-case is to create a new logger without any prefixes.
23+
// // Create a logger without any prefixes.
2424
// logger := log.New()
2525
// logger.Info("Hello, World!")
2626
//
27-
// // We can also add a prefix for our logger. Here, 'MYAPP' will be
28-
// // prepended to each log message.
27+
// // Create a logger with a single prefix 'MYAPP'.
2928
// loggerWithPrefix := log.New("MYAPP")
3029
// loggerWithPrefix.Info("Hello, World!")
3130
//
32-
// // If multiple prefixes are provided, they will be joined with hyphens.
33-
// // Here, 'MYAPP-PREFIX' will be prepended to each log message.
31+
// // Create a logger with multiple prefixes 'MYAPP' and 'PREFIX'.
32+
// // The prefixes will be joined as 'MYAPP-PREFIX'.
3433
// loggerWithMultiplePrefixes := log.New("MYAPP", "PREFIX")
3534
// loggerWithMultiplePrefixes.Info("Hello, World!")
3635
//
37-
// // Any leading and trailing whitespace characters are removed from
38-
// // prefixes. 'MYAPP-PREFIX' will be prepended to each log message.
36+
// // Create a logger with prefixes containing leading/trailing whitespace.
37+
// // The whitespace is removed and prefixes are joined as 'MYAPP-PREFIX'.
3938
// loggerWithWhitespace := log.New(" MYAPP ", " PREFIX ")
4039
// loggerWithWhitespace.Info("Hello, World!")
40+
//
41+
// Parameters:
42+
//
43+
// prefixes: Optional string values to prepend to each log message.
44+
// If multiple prefixes are provided, they will be concatenated
45+
// with hyphens.
46+
//
47+
// Returns:
48+
//
49+
// A new Logger instance configured with the provided prefixes.
4150
func New(prefixes ...string) *Logger {
4251
// Generate prefix.
4352
prefix := ""

0 commit comments

Comments
 (0)