mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-19 06:07:48 +02:00
fixed logs printer dev tests
This commit is contained in:
parent
53ee5212bc
commit
f1a6c19309
@ -33,6 +33,8 @@
|
|||||||
- Updated the `cron.Start()` to start the ticker at the `00` second of the cron interval ([#4394](https://github.com/pocketbase/pocketbase/discussions/4394)).
|
- Updated the `cron.Start()` to start the ticker at the `00` second of the cron interval ([#4394](https://github.com/pocketbase/pocketbase/discussions/4394)).
|
||||||
_Note that the cron format has only minute granularity and there is still no guarantee that the sheduled job will be always executed at the `00` second._
|
_Note that the cron format has only minute granularity and there is still no guarantee that the sheduled job will be always executed at the `00` second._
|
||||||
|
|
||||||
|
- Fixed cron auto backups not taking in consideration the latest settings change ([#4431](https://github.com/pocketbase/pocketbase/discussions/4431)).
|
||||||
|
|
||||||
- Upgraded to `aws-sdk-go-v2` and added special handling for GCS to workaround the previous [GCS headers signature issue](https://github.com/pocketbase/pocketbase/issues/2231) that we had with v2.
|
- Upgraded to `aws-sdk-go-v2` and added special handling for GCS to workaround the previous [GCS headers signature issue](https://github.com/pocketbase/pocketbase/issues/2231) that we had with v2.
|
||||||
_This should also fix the SVG/JSON zero response when using Cloudflare R2 ([#4287](https://github.com/pocketbase/pocketbase/issues/4287#issuecomment-1925168142), [#2068](https://github.com/pocketbase/pocketbase/discussions/2068), [#2952](https://github.com/pocketbase/pocketbase/discussions/2952))._
|
_This should also fix the SVG/JSON zero response when using Cloudflare R2 ([#4287](https://github.com/pocketbase/pocketbase/issues/4287#issuecomment-1925168142), [#2068](https://github.com/pocketbase/pocketbase/discussions/2068), [#2952](https://github.com/pocketbase/pocketbase/discussions/2952))._
|
||||||
_If you are using S3 for uploaded files or backups, please verify that you have a green check in the Admin UI for your S3 configuration (I've tested the new version with GCS, MinIO, Cloudflare R2 and Wasabi)._
|
_If you are using S3 for uploaded files or backups, please verify that you have a green check in the Admin UI for your S3 configuration (I've tested the new version with GCS, MinIO, Cloudflare R2 and Wasabi)._
|
||||||
|
35
core/base.go
35
core/base.go
@ -599,10 +599,10 @@ func (app *BaseApp) RefreshSettings() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// reload handler level (if initialized and not in dev mode)
|
// reload handler level (if initialized)
|
||||||
if !app.IsDev() && app.Logger() != nil {
|
if app.Logger() != nil {
|
||||||
if h, ok := app.Logger().Handler().(*logger.BatchHandler); ok {
|
if h, ok := app.Logger().Handler().(*logger.BatchHandler); ok {
|
||||||
h.SetLevel(slog.Level(app.settings.Logs.MinLevel))
|
h.SetLevel(app.getLoggerMinLevel())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,25 +1184,34 @@ func (app *BaseApp) registerDefaultHooks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *BaseApp) initLogger() error {
|
// getLoggerMinLevel returns the logger min level based on the
|
||||||
duration := 3 * time.Second
|
// app configurations (dev mode, settings, etc.).
|
||||||
ticker := time.NewTicker(duration)
|
|
||||||
done := make(chan bool)
|
|
||||||
|
|
||||||
// Apply the min level only if it is not in develop
|
// If not in dev mode - returns the level from the app settings.
|
||||||
// to allow printing the logs to the console.
|
//
|
||||||
//
|
// If the app is in dev mode it returns -9999 level allowing to print
|
||||||
// DB logs are still filtered but the checks for the min level are done
|
// practically all logs to the terminal.
|
||||||
// in the BatchOptions.BeforeAddFunc instead of the slog.Handler.Enabled() method.
|
// In this case DB logs are still filtered but the checks for the min level are done
|
||||||
|
// in the BatchOptions.BeforeAddFunc instead of the slog.Handler.Enabled() method.
|
||||||
|
func (app *BaseApp) getLoggerMinLevel() slog.Level {
|
||||||
var minLevel slog.Level
|
var minLevel slog.Level
|
||||||
|
|
||||||
if app.IsDev() {
|
if app.IsDev() {
|
||||||
minLevel = -9999
|
minLevel = -9999
|
||||||
} else if app.Settings() != nil {
|
} else if app.Settings() != nil {
|
||||||
minLevel = slog.Level(app.Settings().Logs.MinLevel)
|
minLevel = slog.Level(app.Settings().Logs.MinLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return minLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *BaseApp) initLogger() error {
|
||||||
|
duration := 3 * time.Second
|
||||||
|
ticker := time.NewTicker(duration)
|
||||||
|
done := make(chan bool)
|
||||||
|
|
||||||
handler := logger.NewBatchHandler(logger.BatchOptions{
|
handler := logger.NewBatchHandler(logger.BatchOptions{
|
||||||
Level: minLevel,
|
Level: app.getLoggerMinLevel(),
|
||||||
BatchSize: 200,
|
BatchSize: 200,
|
||||||
BeforeAddFunc: func(ctx context.Context, log *logger.Log) bool {
|
BeforeAddFunc: func(ctx context.Context, log *logger.Log) bool {
|
||||||
if app.IsDev() {
|
if app.IsDev() {
|
||||||
|
@ -251,7 +251,12 @@ func (app *BaseApp) initAutobackupHooks() error {
|
|||||||
// make sure that app.Settings() is always up to date
|
// make sure that app.Settings() is always up to date
|
||||||
//
|
//
|
||||||
// @todo remove with the refactoring as core.App and daos.Dao will be one.
|
// @todo remove with the refactoring as core.App and daos.Dao will be one.
|
||||||
app.RefreshSettings()
|
if err := app.RefreshSettings(); err != nil {
|
||||||
|
app.Logger().Debug(
|
||||||
|
"[Backup cron] Failed to get the latest app settings",
|
||||||
|
slog.String("error", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
rawSchedule := app.Settings().Backups.Cron
|
rawSchedule := app.Settings().Backups.Cron
|
||||||
if rawSchedule == "" || !isServe || !app.IsBootstrapped() {
|
if rawSchedule == "" || !isServe || !app.IsBootstrapped() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user