-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
- Loading branch information
1 parent
b5bf651
commit 34b27db
Showing
8 changed files
with
117 additions
and
167 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,37 @@ | ||
package dexcore | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"decred.org/dcrdex/dex" | ||
libutils "github.com/crypto-power/cryptopower/libwallet/utils" | ||
"github.com/jrick/logrotate/rotator" | ||
) | ||
|
||
var dexLogFile = "dexc.log" | ||
|
||
// NewDexLogger initializes a new dex.Logger. | ||
func NewDexLogger(logDir, lvl string, maxRolls int) (dex.Logger, func(), error) { | ||
err := os.MkdirAll(logDir, libutils.UserFilePerm) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("failed to create log directory: %w", err) | ||
} | ||
|
||
r, err := rotator.New(filepath.Join(logDir, dexLogFile), 32*1024, false, maxRolls) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("failed to create file rotator: %w", err) | ||
} | ||
|
||
logCloser := func() { | ||
r.Close() | ||
} | ||
|
||
l, err := dex.NewLoggerMaker(r, lvl, true /* TODO: Make configurable */) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("Failed to initialize log: %w", err) | ||
} | ||
|
||
return l.NewLogger("DEXC"), logCloser, 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 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
Oops, something went wrong.