-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up plugin logger initialization
- Loading branch information
Janelle Law
committed
Oct 18, 2023
1 parent
41fd599
commit b5c314a
Showing
9 changed files
with
60 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package logger | ||
|
||
import ( | ||
"io" | ||
"sync" | ||
) | ||
|
||
type fileWriter struct { | ||
w io.Writer | ||
mu *sync.Mutex | ||
} | ||
|
||
func InitPluginWriter(agentId string) io.Writer { | ||
sharedPluginWriter.mu.Lock() | ||
defer sharedPluginWriter.mu.Unlock() | ||
if sharedPluginWriter.w != nil { | ||
return sharedPluginWriter.w | ||
} | ||
|
||
f := WriteOnlyFile(agentId) | ||
writer := f.(io.Writer) | ||
sharedPluginWriter.w = writer | ||
return writer | ||
} | ||
|
||
func (fw fileWriter) Write(b []byte) (int, error) { | ||
fw.mu.Lock() | ||
defer fw.mu.Unlock() | ||
if fw.w == nil { | ||
return 0, nil | ||
} | ||
|
||
n, err := fw.w.Write(b) | ||
if err != nil { | ||
return n, err | ||
} | ||
|
||
return n, nil | ||
} |
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 was deleted.
Oops, something went wrong.
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
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