-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: process all config fragments as golang templates (#114)
### Description OB-37310 Process all config fragments as golang templates Replaces #100 and #111 ### Checklist - [x] Created tests which fail without the change (if possible) - [ ] Extended the README / documentation, if necessary Co-authored-by: Alex Lew <[email protected]>
- Loading branch information
1 parent
0d2a488
commit c3b2bb3
Showing
19 changed files
with
925 additions
and
45 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
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
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,37 @@ | ||
package logger | ||
|
||
import ( | ||
"context" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
type ctxKey struct{} | ||
|
||
func Get() *zap.Logger { | ||
logger, _ := zap.NewProduction() | ||
return logger | ||
} | ||
|
||
func GetDev() *zap.Logger { | ||
logger, _ := zap.NewDevelopment() | ||
return logger | ||
} | ||
|
||
func FromCtx(ctx context.Context) *zap.Logger { | ||
if l, ok := ctx.Value(ctxKey{}).(*zap.Logger); ok { | ||
return l | ||
} | ||
|
||
return Get() | ||
} | ||
|
||
func WithCtx(ctx context.Context, l *zap.Logger) context.Context { | ||
if lp, ok := ctx.Value(ctxKey{}).(*zap.Logger); ok { | ||
if lp == l { | ||
return ctx | ||
} | ||
} | ||
|
||
return context.WithValue(ctx, ctxKey{}, l) | ||
} |
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
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
Oops, something went wrong.