Skip to content
cloudemu
Services

Documentation

Logging

Log groups, streams, and event queries, modelled on CloudWatch Logs, Log Analytics, Cloud Logging, and OCI Logging

aws CloudWatch Logsazr Log Analyticsgcp Cloud Loggingoci Logging

Emulates a managed log store — the CloudWatch Logs pipeline your app writes events into and you later query. You create a log group, open a stream within it, put events onto the stream, then read them back by time range.

Reach for it when your code emits log events, sets retention, or queries a window of history — so you can exercise those paths without a live logging backend. Under the hood a group is a named container, a stream is an ordered sequence of timestamped events inside it, and a query filters that sequence by time.

ProviderServiceSDK-compatDriver
AWSCloudWatch Logs✓ Liveaws.CloudWatchLogs
AzureLog Analytics✓ Liveazure.LogAnalytics
GCPCloud Logging✓ Livegcp.CloudLogging
OCILogging (log groups, logs, ingestion, search)✓ Liveoci.Logging

Create groups and streams, then write events#

A log group is the top-level container (with a retention window), a stream is a single source of events within it, and PutLogEvents appends timestamped messages — the same three steps you'd take with CloudWatch Logs:

import logdriver "github.com/stackshy/cloudemu/v2/services/logging/driver"

// Create a log group
aws.CloudWatchLogs.CreateLogGroup(ctx, logdriver.LogGroupConfig{
    Name:           "/app/web",
    RetentionDays:  30,
})

// Create a log stream
aws.CloudWatchLogs.CreateLogStream(ctx, "/app/web", "instance-001")

// Put log events
aws.CloudWatchLogs.PutLogEvents(ctx, "/app/web", "instance-001", []logdriver.LogEvent{
    {Timestamp: time.Now(), Message: "Server started on port 8080"},
    {Timestamp: time.Now(), Message: "Handling request GET /api/users"},
})

Query events#

GetLogEvents reads back a stream over a time window with a limit, the way you'd scan recent history in the console or an alerting job:

events, _ := aws.CloudWatchLogs.GetLogEvents(ctx, "/app/web", "instance-001",
    logdriver.GetLogEventsInput{
        StartTime: time.Now().Add(-1 * time.Hour),
        Limit:     100,
    })

To test retention or time-windowed queries without waiting, drive time with the fake clock: advance the clock and query a window that spans the jump.

Behavior & fidelity#

BehaviorWhat happens
Timestamped, time-ordered eventsA query filters a stream by StartTime and caps results with Limit, so you assert on exactly the window your code reads.
Named groups and streamsEvents live under a group name and a stream name, matching how CloudWatch Logs namespaces a source.

SDK-compat — Live#

Real CloudWatch Logs, Log Analytics, and Cloud Logging clients drive it end-to-end. See SDK-Compat for the full operation list.

On this page

On this page