diff --git a/api.go b/api.go index c09436c1..e984d37e 100644 --- a/api.go +++ b/api.go @@ -86,7 +86,7 @@ func Serve() { if !viper.GetBool("production") { go func() { - log.Ctx(ctx).Err(http.ListenAndServe("0.0.0.0:6060", nil)).Msg("Debug server") + log.Err(http.ListenAndServe("0.0.0.0:6060", nil)).Msg("Debug server") }() } @@ -236,7 +236,7 @@ func Serve() { bytesIn = "0" } - log.Ctx(ctx).Info(). + log.Info(). Str("time_rfc3339", time.Now().Format(time.RFC3339)). Str("remote_ip", c.RealIP()). Str("host", req.Host). @@ -266,7 +266,7 @@ func Serve() { }() address := fmt.Sprintf(":%d", viper.GetInt("port")) - log.Ctx(ctx).Info().Str("address", address).Msg("starting server") + log.Info().Str("address", address).Msg("starting server") e.HidePort = true e.Logger.Error(e.Start(address)) @@ -276,7 +276,7 @@ func installExportPipeline(ctx context.Context) func() { client := otlptracehttp.NewClient() exporter, err := otlptrace.New(ctx, client) if err != nil { - log.Ctx(ctx).Fatal().Err(err).Msg("creating OTLP trace exporter") + log.Fatal().Err(err).Msg("creating OTLP trace exporter") } tracerProvider := sdktrace.NewTracerProvider( @@ -288,7 +288,7 @@ func installExportPipeline(ctx context.Context) func() { return func() { if err := tracerProvider.Shutdown(ctx); err != nil { - log.Ctx(ctx).Fatal().Err(err).Msg("stopping tracer provider") + log.Fatal().Err(err).Msg("stopping tracer provider") } } } diff --git a/config/config.go b/config/config.go index 425a8b90..48739182 100644 --- a/config/config.go +++ b/config/config.go @@ -33,10 +33,10 @@ func InitializeConfig() context.Context { ctx := log.Logger.WithContext(context.Background()) if err != nil { - log.Ctx(ctx).Warn().Err(err).Msg("config initialized using defaults and environment only!") + log.Warn().Err(err).Msg("config initialized using defaults and environment only!") } - log.Ctx(ctx).Info().Msg("Config initialized") + log.Info().Msg("Config initialized") return ctx } diff --git a/db/postgres/postgres.go b/db/postgres/postgres.go index 6df0d17e..c104b89e 100644 --- a/db/postgres/postgres.go +++ b/db/postgres/postgres.go @@ -35,15 +35,15 @@ func (l *GormLogger) LogMode(mode logger.LogLevel) logger.Interface { } func (*GormLogger) Info(ctx context.Context, msg string, data ...interface{}) { - log.Ctx(ctx).Info().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + log.Info().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) } func (*GormLogger) Warn(ctx context.Context, msg string, data ...interface{}) { - log.Ctx(ctx).Warn().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + log.Warn().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) } func (*GormLogger) Error(ctx context.Context, msg string, data ...interface{}) { - log.Ctx(ctx).Error().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) + log.Error().Str("file", utils.FileWithLineNum()).Msgf(msg, data...) } func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { @@ -52,16 +52,14 @@ func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (stri sql, rows := fc() - logCtx := log.Ctx(ctx) - var logEv *zerolog.Event switch { case err != nil: - logEv = logCtx.Err(err) + logEv = log.Err(err) case since > l.SlowThreshold && l.SlowThreshold != 0: - logEv = logCtx.Warn() + logEv = log.Warn() case l.Debug: - logEv = logCtx.Info() + logEv = log.Info() } if logEv != nil { @@ -102,7 +100,7 @@ func InitializePostgres(ctx context.Context) { // TODO Create search indexes - log.Ctx(ctx).Info().Msg("Postgres initialized") + log.Info().Msg("Postgres initialized") } func Save(ctx context.Context, object interface{}) { diff --git a/db/statistics.go b/db/statistics.go index 48aafeb5..6db61144 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -18,7 +18,7 @@ func RunAsyncStatisticLoop(ctx context.Context) { for { start := time.Now() keys := redis.GetAllKeys() - log.Ctx(ctx).Info().Msgf("Fetched: %d keys in %s", len(keys), time.Since(start).String()) + log.Info().Msgf("Fetched: %d keys in %s", len(keys), time.Since(start).String()) resultMap := make(map[string]map[string]map[string]uint) for _, key := range keys { if matches := keyRegex.FindStringSubmatch(key); matches != nil { @@ -104,7 +104,7 @@ func RunAsyncStatisticLoop(ctx context.Context) { updateTx.Commit() } - log.Ctx(ctx).Info().Msgf("Statistics Updated! Took %s", time.Since(start).String()) + log.Info().Msgf("Statistics Updated! Took %s", time.Since(start).String()) time.Sleep(time.Minute) } }() diff --git a/gql/resolver_versions.go b/gql/resolver_versions.go index b2f0c768..c6430626 100644 --- a/gql/resolver_versions.go +++ b/gql/resolver_versions.go @@ -100,12 +100,12 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri return false, errors.New("you must update your mod reference on the site to match your mod_reference in your data.json") } - log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finalization gql call") + log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finalization gql call") go func(ctx context.Context, mod *postgres.Mod, versionID string, version generated.NewVersion) { defer func() { if r := recover(); r != nil { - log.Ctx(ctx).Error().Interface("recover", r).Str("stack", string(debug.Stack())).Msgf("recovered from version finalization") + log.Error().Interface("recover", r).Str("stack", string(debug.Stack())).Msgf("recovered from version finalization") if err := redis.StoreVersionUploadState(versionID, nil, errors.New("internal error, please try again, if it fails again, please report on discord")); err != nil { log.Error().Err(err).Msg("failed to store version upload state") @@ -113,20 +113,20 @@ func (r *mutationResolver) FinalizeCreateVersion(ctx context.Context, modID stri } }() - log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("calling FinalizeVersionUploadAsync") + log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("calling FinalizeVersionUploadAsync") data, err := FinalizeVersionUploadAsync(ctx, mod, versionID, version) if err2 := redis.StoreVersionUploadState(versionID, data, err); err2 != nil { - log.Ctx(ctx).Err(err2).Msg("error storing redis state") + log.Err(err2).Msg("error storing redis state") return } - log.Ctx(ctx).Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finished FinalizeVersionUploadAsync") + log.Info().Str("mod_id", mod.ID).Str("version_id", versionID).Msg("finished FinalizeVersionUploadAsync") if err != nil { - log.Ctx(ctx).Err(err).Msgf("error completing version upload [%s]", versionID) + log.Err(err).Msgf("error completing version upload [%s]", versionID) } else { - log.Ctx(ctx).Info().Msgf("completed version upload: %s", versionID) + log.Info().Msgf("completed version upload: %s", versionID) } }(util.ReWrapCtx(ctx), mod, versionID, version) diff --git a/gql/versions.go b/gql/versions.go index 8c52aed7..2f728378 100644 --- a/gql/versions.go +++ b/gql/versions.go @@ -116,7 +116,7 @@ func FinalizeVersionUploadAsync(ctx context.Context, mod *postgres.Mod, versionI jsonData, err := json.Marshal(modInfo.Metadata) if err != nil { - log.Ctx(ctx).Err(err).Msgf("[%s] failed serializing", dbVersion.ID) + log.Err(err).Msgf("[%s] failed serializing", dbVersion.ID) } else { metadata := string(jsonData) dbVersion.Metadata = &metadata diff --git a/integrations/discord.go b/integrations/discord.go index 2865f5db..c9234ce8 100644 --- a/integrations/discord.go +++ b/integrations/discord.go @@ -61,7 +61,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { payloadJSON, err := json.Marshal(payload) if err != nil { - log.Ctx(ctx).Err(err).Msg("error marshaling discord webhook") + log.Err(err).Msg("error marshaling discord webhook") return } @@ -80,7 +80,7 @@ func NewMod(ctx context.Context, mod *postgres.Mod) { } func NewVersion(ctx context.Context, version *postgres.Version) { - log.Ctx(ctx).Info().Str("stack", string(debug.Stack())).Msg("new version discord webhook") + log.Info().Str("stack", string(debug.Stack())).Msg("new version discord webhook") if version == nil { return @@ -146,7 +146,7 @@ func NewVersion(ctx context.Context, version *postgres.Version) { payloadJSON, err := json.Marshal(payload) if err != nil { - log.Ctx(ctx).Err(err).Msg("error marshaling discord webhook") + log.Err(err).Msg("error marshaling discord webhook") return } diff --git a/migrations/code.go b/migrations/code.go index da9d806e..556a5934 100644 --- a/migrations/code.go +++ b/migrations/code.go @@ -3,11 +3,10 @@ package migrations import ( "context" "os" + "strings" postgres2 "github.com/satisfactorymodding/smr-api/db/postgres" - "strings" - // Import all migrations _ "github.com/satisfactorymodding/smr-api/migrations/code" @@ -32,7 +31,7 @@ func codeMigrations(ctx context.Context) { source := migration.DefaultCodeSource() // TODO Custom reporter, this one's very ugly - reporter := migration.NewDefaultReporterWithParams(codeMigrationLogger{log: log.Ctx(ctx)}, os.Exit) + reporter := migration.NewDefaultReporterWithParams(codeMigrationLogger{log: &log.Logger}, os.Exit) db, _ := postgres2.DBCtx(ctx).DB() manager := migration.NewDefaultManager(migration.NewPostgreSQLTarget(db), source) diff --git a/migrations/migrations.go b/migrations/migrations.go index 20a80281..5bf8cf18 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -18,7 +18,7 @@ import ( func RunMigrations(ctx context.Context) { databaseMigrations(ctx) codeMigrations(ctx) - log.Ctx(ctx).Info().Msg("Migrations Complete") + log.Info().Msg("Migrations Complete") } func databaseMigrations(ctx context.Context) { diff --git a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go index 6cd08ea6..0f499b22 100644 --- a/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go +++ b/redis/jobs/consumers/consumer_scan_mod_on_virus_total.go @@ -37,7 +37,7 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { return errors.Wrap(err, "failed to unmarshal task data") } - log.Ctx(ctx).Info().Msgf("starting virus scan of mod %s version %s", task.ModID, task.VersionID) + log.Info().Msgf("starting virus scan of mod %s version %s", task.ModID, task.VersionID) version := postgres.GetVersion(ctx, task.VersionID) link := storage.GenerateDownloadLink(version.Key) @@ -78,12 +78,12 @@ func ScanModOnVirusTotalConsumer(ctx context.Context, payload []byte) error { } if !success { - log.Ctx(ctx).Warn().Msgf("mod %s version %s failed to pass virus scan", task.ModID, task.VersionID) + log.Warn().Msgf("mod %s version %s failed to pass virus scan", task.ModID, task.VersionID) return nil } if task.ApproveAfter { - log.Ctx(ctx).Info().Msgf("approving mod %s version %s after successful virus scan", task.ModID, task.VersionID) + log.Info().Msgf("approving mod %s version %s after successful virus scan", task.ModID, task.VersionID) version.Approved = true postgres.Save(ctx, &version) diff --git a/redis/jobs/consumers/utils.go b/redis/jobs/consumers/utils.go index 63da8808..31ae1323 100644 --- a/redis/jobs/consumers/utils.go +++ b/redis/jobs/consumers/utils.go @@ -17,7 +17,7 @@ import ( func UpdateModDataFromStorage(ctx context.Context, modID string, versionID string, metadata bool) error { // perform task - log.Ctx(ctx).Info().Msgf("[%s] Updating DB for mod %s version with metadata: %v", versionID, modID, metadata) + log.Info().Msgf("[%s] Updating DB for mod %s version with metadata: %v", versionID, modID, metadata) version := postgres.GetVersion(ctx, versionID) link := storage.GenerateDownloadLink(version.Key) @@ -39,7 +39,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin info, err := validation.ExtractModInfo(ctx, fileData, metadata, false, mod.ModReference) if err != nil { - log.Ctx(ctx).Warn().Err(err).Msgf("[%s] Failed updating mod, likely outdated", versionID) + log.Warn().Err(err).Msgf("[%s] Failed updating mod, likely outdated", versionID) // Outdated version return nil } @@ -69,7 +69,7 @@ func UpdateModDataFromStorage(ctx context.Context, modID string, versionID strin if metadata { jsonData, err := json.Marshal(info.Metadata) if err != nil { - log.Ctx(ctx).Err(err).Msgf("[%s] failed serializing", versionID) + log.Err(err).Msgf("[%s] failed serializing", versionID) } else { metadata := string(jsonData) version.Metadata = &metadata diff --git a/redis/jobs/jobs.go b/redis/jobs/jobs.go index 6b49386e..d0a70e27 100644 --- a/redis/jobs/jobs.go +++ b/redis/jobs/jobs.go @@ -55,7 +55,7 @@ func SubmitJobUpdateDBFromModVersionFileTask(ctx context.Context, modID string, err := queue.Add(tasks.UpdateDBFromModVersionFileTask.WithArgs(ctx, task)) if err != nil { - log.Ctx(ctx).Err(err).Msg("error adding task") + log.Err(err).Msg("error adding task") } } @@ -68,7 +68,7 @@ func SubmitJobUpdateDBFromModVersionJSONFileTask(ctx context.Context, modID stri err := queue.Add(tasks.UpdateDBFromModVersionJSONFileTask.WithArgs(ctx, task)) if err != nil { - log.Ctx(ctx).Err(err).Msg("error adding task") + log.Err(err).Msg("error adding task") } } @@ -80,7 +80,7 @@ func SubmitJobCopyObjectFromOldBucketTask(ctx context.Context, key string) { err := queue.Add(tasks.CopyObjectFromOldBucketTask.WithArgs(ctx, task)) if err != nil { - log.Ctx(ctx).Err(err).Msg("error adding task") + log.Err(err).Msg("error adding task") } } @@ -92,7 +92,7 @@ func SubmitJobCopyObjectToOldBucketTask(ctx context.Context, key string) { err := queue.Add(tasks.CopyObjectToOldBucketTask.WithArgs(ctx, task)) if err != nil { - log.Ctx(ctx).Err(err).Msg("error adding task") + log.Err(err).Msg("error adding task") } } @@ -106,6 +106,6 @@ func SubmitJobScanModOnVirusTotalTask(ctx context.Context, modID string, version err := queue.Add(tasks.ScanModOnVirusTotalTask.WithArgs(ctx, task)) if err != nil { - log.Ctx(ctx).Err(err).Msg("error adding task") + log.Err(err).Msg("error adding task") } } diff --git a/redis/redis.go b/redis/redis.go index 120a48e2..4a9e7df6 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -38,7 +38,7 @@ func InitializeRedis(ctx context.Context) { panic(ping.Err()) } - log.Ctx(ctx).Info().Msg("Redis initialized") + log.Info().Msg("Redis initialized") } func CanIncrement(ip string, action string, object string, expiration time.Duration) bool { diff --git a/storage/b2.go b/storage/b2.go index 581d23a7..ceb1f746 100644 --- a/storage/b2.go +++ b/storage/b2.go @@ -36,7 +36,7 @@ func initializeB2(ctx context.Context, config Config) *B2 { newSession, err := session.NewSession(s3Config) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to create S3 session") + log.Err(err).Msg("failed to create S3 session") return nil } diff --git a/storage/s3.go b/storage/s3.go index 4293ea3f..41aa84e9 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -38,7 +38,7 @@ func initializeS3(ctx context.Context, config Config) *S3 { newSession, err := session.NewSession(s3Config) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to create S3 session") + log.Err(err).Msg("failed to create S3 session") return nil } diff --git a/storage/storage.go b/storage/storage.go index eb93001b..c0de9206 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -61,7 +61,7 @@ func InitializeStorage(ctx context.Context) { panic("Failed to initialize storage!") } - log.Ctx(ctx).Info().Msgf("Storage initialized: %s", baseConfig.Type) + log.Info().Msgf("Storage initialized: %s", baseConfig.Type) } func configToStorage(ctx context.Context, config Config) Storage { @@ -88,7 +88,7 @@ func StartUploadMultipartMod(ctx context.Context, modID string, name string, ver key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := StartMultipartUpload(key); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to upload mod") + log.Err(err).Msg("failed to upload mod") return false, "" } @@ -106,7 +106,7 @@ func UploadMultipartMod(ctx context.Context, modID string, name string, versionI key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := UploadPart(key, part, data); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to upload mod") + log.Err(err).Msg("failed to upload mod") return false, "" } @@ -124,7 +124,7 @@ func CompleteUploadMultipartMod(ctx context.Context, modID string, name string, key := fmt.Sprintf("/mods/%s/%s.smod", modID, filename) if err := CompleteMultipartUpload(key); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to upload mod") + log.Err(err).Msg("failed to upload mod") return false, "" } @@ -141,7 +141,7 @@ func UploadModLogo(ctx context.Context, modID string, data io.ReadSeeker) (bool, key, err := storage.Put(ctx, key, data) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to upload mod logo") + log.Err(err).Msg("failed to upload mod logo") return false, "" } @@ -164,12 +164,12 @@ func UploadUserAvatar(ctx context.Context, userID string, data io.ReadSeeker) (b retry.Attempts(3), retry.LastErrorOnly(true), retry.OnRetry(func(n uint, err error) { - log.Ctx(ctx).Err(err).Msgf("failed to upload user avatar, retrying [%d]", n) + log.Err(err).Msgf("failed to upload user avatar, retrying [%d]", n) }), ) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to upload user avatar") + log.Err(err).Msg("failed to upload user avatar") return false, "" } @@ -256,16 +256,16 @@ func RenameVersion(ctx context.Context, modID string, name string, versionID str from := fmt.Sprintf("/mods/%s/%s.smod", modID, EncodeName(cleanName)+"-"+versionID) to := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+version) - log.Ctx(ctx).Info().Msgf("Renaming file from %s to %s", from, to) + log.Info().Msgf("Renaming file from %s to %s", from, to) if err := storage.Rename(from, to); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to rename version") + log.Err(err).Msg("failed to rename version") return false, "" } fromUnescaped := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+versionID) if err := storage.Delete(fromUnescaped); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to delete version") + log.Err(err).Msg("failed to delete version") return false, "" } @@ -282,7 +282,7 @@ func DeleteMod(ctx context.Context, modID string, name string, versionID string) key := fmt.Sprintf("/mods/%s/%s.smod", modID, cleanName+"-"+versionID) if err := storage.Delete(key); err != nil { - log.Ctx(ctx).Err(err).Msg("failed to delete version") + log.Err(err).Msg("failed to delete version") return false } @@ -300,7 +300,7 @@ func ModVersionMeta(ctx context.Context, modID string, name string, versionID st meta, err := storage.Meta(key) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to delete version") + log.Err(err).Msg("failed to delete version") return nil } diff --git a/storage/wasabi.go b/storage/wasabi.go index aba9d365..3a9e9570 100644 --- a/storage/wasabi.go +++ b/storage/wasabi.go @@ -32,7 +32,7 @@ func initializeWasabi(ctx context.Context, config Config) *Wasabi { newSession, err := session.NewSession(s3Config) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed to create session") + log.Err(err).Msg("failed to create session") return nil } diff --git a/util/converter/converter_linux.go b/util/converter/converter_linux.go index ee12a134..0687354c 100644 --- a/util/converter/converter_linux.go +++ b/util/converter/converter_linux.go @@ -27,7 +27,7 @@ func ConvertAnyImageToWebp(ctx context.Context, imageAsBytes []byte) ([]byte, er if err != nil { message := "error converting image to webp" - log.Ctx(ctx).Err(err).Msg(message) + log.Err(err).Msg(message) return nil, errors.Wrap(err, message) } @@ -38,7 +38,7 @@ func ConvertAnyImageToWebp(ctx context.Context, imageAsBytes []byte) ([]byte, er if err != nil { message := "error converting image to webp" - log.Ctx(ctx).Err(err).Msg(message) + log.Err(err).Msg(message) return nil, errors.Wrap(err, message) } diff --git a/util/converter/converter_windows.go b/util/converter/converter_windows.go index 577b939f..02a77a7b 100755 --- a/util/converter/converter_windows.go +++ b/util/converter/converter_windows.go @@ -16,7 +16,7 @@ func ConvertAnyImageToWebp(imageAsBytes []byte) ([]byte, error) { if err != nil { err := errors.Wrap(err, "error converting image to webp") - log.Ctx(ctx).Error(err) + log.Error(err) return nil, err } diff --git a/validation/decoderv2.go b/validation/decoderv2.go index 117b2b10..b9d5fb0d 100644 --- a/validation/decoderv2.go +++ b/validation/decoderv2.go @@ -48,10 +48,10 @@ func DecodeProperty(ctx context.Context, cleanName string, property *parser.FPro } else if b, ok := property.Tag.(byte); ok { return b } else { - log.Ctx(ctx).Error().Msgf("Unknown ByteProperty type: %#v", property) + log.Error().Msgf("Unknown ByteProperty type: %#v", property) } default: - log.Ctx(ctx).Error().Msgf("Unknown property type [%s]: %s", cleanName, property.PropertyType) + log.Error().Msgf("Unknown property type [%s]: %s", cleanName, property.PropertyType) } return nil @@ -110,7 +110,7 @@ func DecodeArrayProperty(ctx context.Context, property *parser.FPropertyTag) []i case "FloatProperty": copy(results, arrayData) default: - log.Ctx(ctx).Error().Msgf("Unknown array property data type [%s]: %s", property.Name, property.TagData.(string)) + log.Error().Msgf("Unknown array property data type [%s]: %s", property.Name, property.TagData.(string)) } return results diff --git a/validation/paks.go b/validation/paks.go index a0d70f4a..3e758e64 100644 --- a/validation/paks.go +++ b/validation/paks.go @@ -206,7 +206,7 @@ func ExtractDataFromPak(ctx context.Context, reader parser.PakReader) map[string if _, ok := ignoredClasses[cleanName]; !ok { if !strings.HasPrefix(cleanName, "Widget_") && !strings.HasPrefix(cleanName, "ParticleModule") { - log.Ctx(ctx).Warn().Msgf("Parsing unknown class name: %s", cleanName) + log.Warn().Msgf("Parsing unknown class name: %s", cleanName) if _, ok := exportData[cleanName]; !ok { exportData[cleanName] = make([]interface{}, 0) diff --git a/validation/paks_test.go b/validation/paks_test.go index c1058d40..6d31c40b 100644 --- a/validation/paks_test.go +++ b/validation/paks_test.go @@ -45,7 +45,7 @@ func TestExtractDataFromPak(t *testing.T) { pakData, err := AttemptExtractDataFromPak(ctx, reader) if err != nil { - log.Ctx(ctx).Err(err).Msg("error parsing pak") + log.Err(err).Msg("error parsing pak") t.Error(err) } else { marshal, _ := json.MarshalIndent(pakData, "", " ") diff --git a/validation/validation.go b/validation/validation.go index 1dc1ef98..19e72938 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -115,14 +115,14 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal data, err := archiveFile.Open() if err != nil { - log.Ctx(ctx).Err(err).Msg("failed opening archive file") + log.Err(err).Msg("failed opening archive file") break } pakData, err := ioutil.ReadAll(data) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed reading archive file") + log.Err(err).Msg("failed reading archive file") break } @@ -133,7 +133,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal pak, err := AttemptExtractDataFromPak(ctx, reader) if err != nil { - log.Ctx(ctx).Err(err).Msg("failed parsing archive file") + log.Err(err).Msg("failed parsing archive file") break } @@ -151,7 +151,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal _, err = hash.Write(body) if err != nil { - log.Ctx(ctx).Err(err).Msg("error hashing pak") + log.Err(err).Msg("error hashing pak") } modInfo.Hash = hex.EncodeToString(hash.Sum(nil)) @@ -159,7 +159,7 @@ func ExtractModInfo(ctx context.Context, body []byte, withMetadata bool, withVal version, err := semver.StrictNewVersion(modInfo.Version) if err != nil { - log.Ctx(ctx).Err(err).Msg("error parsing semver") + log.Err(err).Msg("error parsing semver") return nil, errors.Wrap(err, "error parsing semver") } diff --git a/validation/virustotal.go b/validation/virustotal.go index 36e71a2f..9c748874 100644 --- a/validation/virustotal.go +++ b/validation/virustotal.go @@ -42,7 +42,7 @@ func ScanFiles(ctx context.Context, files []io.Reader, names []string) (bool, er analysisID := scan.ID() - log.Ctx(ctx).Info().Msgf("uploaded virus scan for file %s and analysis ID: %s", names[i], analysisID) + log.Info().Msgf("uploaded virus scan for file %s and analysis ID: %s", names[i], analysisID) for { time.Sleep(time.Second * 15)