Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Taskfile.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ tasks:
docs:
dir: docs
cmds:
- npm run dev
- bun run dev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for bun mentions in key documentation files
echo "=== Checking for bun in documentation ==="
find . -maxdepth 3 \( -name "README.md" -o -name "CONTRIBUTING.md" -o -name "package.json" \) | head -20 | while read f; do
  if [ -f "$f" ]; then
    echo "--- File: $f ---"
    rg -i "bun" "$f" || echo "No mention of bun"
  fi
done

echo -e "\n=== Checking Taskfile.dist.yml context ==="
if [ -f "Taskfile.dist.yml" ]; then
  head -40 Taskfile.dist.yml
fi

echo -e "\n=== Looking for bun in all YAML files ==="
rg -i "bun" --type yaml || echo "No bun mentions in YAML files"

Repository: platforma-dev/platforma

Length of output: 919


🏁 Script executed:

#!/bin/bash
# Check the overall tooling and dependencies
echo "=== Checking for package managers references ==="
rg -i "pnpm|npm|yarn|bun" package.json 2>/dev/null | head -20

echo -e "\n=== Check if there's a .node-version, .tool-versions, or similar ==="
ls -la | grep -E "^\." | head -20

echo -e "\n=== Check git history to see what changed ==="
git log --oneline -20 2>/dev/null || echo "Git history not available"

Repository: platforma-dev/platforma

Length of output: 267


🏁 Script executed:

#!/bin/bash
# Check the docs directory structure and dependencies
echo "=== Docs directory structure ==="
ls -la docs/ | head -30

echo -e "\n=== Contents of docs/package.json ==="
if [ -f "docs/package.json" ]; then
  cat docs/package.json
fi

echo -e "\n=== Check for lockfiles in docs ==="
ls -la docs/ | grep -E "lock|yarn|pnpm"

echo -e "\n=== Check if root has package.json ==="
if [ -f "package.json" ]; then
  cat package.json
fi

echo -e "\n=== Check for any dev setup docs ==="
find . -maxdepth 2 -name "*SETUP*" -o -name "*setup*" -o -name "*DEV*" 2>/dev/null | grep -v node_modules | head -10

Repository: platforma-dev/platforma

Length of output: 1371


🏁 Script executed:

#!/bin/bash
# Check the docs README for setup instructions
echo "=== Contents of docs/README.md ==="
cat docs/README.md

Repository: platforma-dev/platforma

Length of output: 1888


Update documentation to reflect bun as the required package manager for docs, or add a fallback.

The docs task now requires bun run dev, but docs/README.md still instructs contributors to use npm install and npm run dev. This mismatch will break the workflow for contributors without bun. Since docs/bun.lock confirms bun is the intended package manager, update docs/README.md to document bun as a requirement, or add a fallback command in the Taskfile to maintain npm compatibility.

🔧 Fallback option for Taskfile
   docs:
     dir: docs
     cmds:
-      - bun run dev
+      - |
+          if command -v bun >/dev/null 2>&1; then
+            bun run dev
+          else
+            npm run dev
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- bun run dev
docs:
dir: docs
cmds:
- |
if command -v bun >/dev/null 2>&1; then
bun run dev
else
npm run dev
fi
🤖 Prompt for AI Agents
In `@Taskfile.dist.yml` at line 27, Update documentation and/or Taskfile to keep
docs build working for contributors without bun: either change docs/README.md to
require bun (mention docs/bun.lock and add install + "bun run dev" instructions)
or modify the Taskfile docs target (replace the single "- bun run dev"
invocation with a fallback that tries bun first then falls back to npm/yarn,
e.g. an OR-style or conditional that runs "bun run dev" and if it fails runs
"npm run dev" or "yarn dev"). Ensure you reference Taskfile's docs target and
docs/README.md so both the task and the README are consistent.

31 changes: 31 additions & 0 deletions demo-app/cmd/wide-events/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"context"
"errors"
"log/slog"
"os"
"time"

"github.com/platforma-dev/platforma/log3"
)

func main() {
logger := log3.NewWideEventLogger(
os.Stdout,
log3.NewDefaultSampler(3*time.Second, 200, 0.1),
"json",
nil,
)

ev := log3.NewEvent("test_event")

ev.AddStep(slog.LevelInfo, "some step")
ev.AddError(errors.New("some error"))
ev.AddAttrs(map[string]any{
"attr1": 1,
"attr2": true,
})

logger.WriteEvent(context.Background(), ev)
}
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"dev": "astro dev --host",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
Expand Down
2 changes: 1 addition & 1 deletion log/log.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package log provides structured logging functionality with context support.
package log
package log //nolint:revive

import (
"context"
Expand Down
42 changes: 42 additions & 0 deletions log2/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Package log2 provides wide-event logging with tail sampling.
package log2

import (
"io"
"log/slog"
"os"
"time"
)

const (
defaultFormat = "json"
defaultKeepStatus = 500
defaultMaxSteps = 100
defaultRandomKeepRate = 0.05
defaultSlowThreshold = 2 * time.Second
)

// Config configures logger behavior.
type Config struct {
Writer io.Writer
Format string
Level slog.Level
ContextKeys map[string]any
Sampler TailSampler
MaxSteps int
}

// DefaultConfig returns default logger configuration.
func DefaultConfig() Config {
return Config{
Writer: os.Stdout,
Format: defaultFormat,
Level: slog.LevelInfo,
Sampler: NewDefaultTailSampler(DefaultTailSamplerConfig{
SlowThreshold: defaultSlowThreshold,
RandomKeepRate: defaultRandomKeepRate,
KeepStatusAtLeast: defaultKeepStatus,
}),
MaxSteps: defaultMaxSteps,
}
}
31 changes: 31 additions & 0 deletions log2/context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package log2

import "context"

type contextKey string

// LogEventContextKey is used to store Event in context.
const LogEventContextKey contextKey = "platformaLogEvent"

// EventFromContext gets an event from context.
func EventFromContext(ctx context.Context) (*Event, bool) {
if ctx == nil {
return nil, false
}

ev, ok := ctx.Value(LogEventContextKey).(*Event)
if !ok || ev == nil {
return nil, false
}

return ev, true
}

// WithEvent stores an event in context.
func WithEvent(ctx context.Context, ev *Event) context.Context {
if ctx == nil {
ctx = context.Background()
}

return context.WithValue(ctx, LogEventContextKey, ev)
}
Loading