Skip to content

Carrot.Data.Scaffold.Compilers.Sinks.Logging

net

Logging sink for the scaffold compiler pipeline. Reports module execution, renderer output counts, and optionally dumps full generated file content.

Installation

xml
<ProjectReference Include="..\Carrot.Data.Scaffold.Compilers.Sinks.Logging\Carrot.Data.Scaffold.Compilers.Sinks.Logging.csproj" />

Architecture

How It Works

ScaffoldCompilerSinkLog extends ScaffoldCompilerSinkMeta<ScaffoldCompilerSinkLogOptions>, making it both a regular sink and a metadata sink. This means it participates in two phases of the pipeline:

Metadata phase (per-module/per-renderer):

  • WriteMeta(module) - logs [Scaffold.ModuleName] when ReportFileCreation is enabled
  • WriteMeta(module, renderer, outputs) - logs [Scaffold.ModuleName.RendererName] Generated N files. with per-file path and line count. Suppresses output for renderers with zero files unless ReportZeroFiles is true.

Sink phase (full bundle):

  • Write(bundle) - when ReportFinalFiles is enabled, dumps the full content of every generated file with *-delimited headers showing file name, extension, and folder.

Options

OptionDefaultDescription
EnabledtrueMaster switch for the sink
ReportFileCreationfalseLog module/renderer names and per-file paths during metadata phase
ReportFinalFilesfalseDump full file content during the sink phase
ReportZeroFilestrueInclude renderers that produced zero files in metadata output

Dependencies

DependencyKind
Carrot.Data.Scaffold.Compilersproject (compiler pipeline framework)

Build

bash
dotnet build

Usage Guide

Logging sink that reports scaffold compilation progress - module names, renderer output counts, file paths, and optionally full file content.

Getting Started

csharp
using Carrot.Data.Scaffold;
using Carrot.Data.Scaffold.Domain;

scaffold.Compiler(compiler =>
{
    compiler
        .AddModule<MyGraphRoot, MyModule>()
        .SinkToLog()
        .SinkToFileSystem()
        .Build();
});

Common Patterns

1. Default (enabled, quiet)

csharp
compiler.SinkToLog();
// Enabled by default but ReportFileCreation and ReportFinalFiles are off,
// so only zero-file renderers are noted.

2. Report file creation progress

csharp
compiler.SinkToLog(options =>
{
    options.ReportFileCreation = true;
});
// Output:
//   [Scaffold.Domain]
//   [Scaffold.Domain.EntityRenderer] Generated 12 files.
//       src/Domain/Entities/User.cs (45 lines)
//       src/Domain/Entities/Order.cs (62 lines)

3. Dump full generated content

csharp
compiler.SinkToLog(options =>
{
    options.ReportFinalFiles = true;
});
// Dumps every file's content with header separators - useful for debugging renderers.

4. Suppress zero-file renderers

csharp
compiler.SinkToLog(options =>
{
    options.ReportFileCreation = true;
    options.ReportZeroFiles    = false;  // skip renderers that produced nothing
});

5. Manual registration (without extension)

csharp
compiler.SinkTo<ScaffoldCompilerSinkLog, ScaffoldCompilerSinkLogOptions>(options =>
{
    options.Enabled            = true;
    options.ReportFileCreation = true;
});

Tips / Gotchas

  • Register before FileSystem sink - sinks execute in registration order. If you want to see log output before files are written, register the log sink first.
  • Metadata callbacks happen during the module loop - WriteMeta is called per-module and per-renderer as they execute, giving real-time progress. The Write method runs later during the sink phase with the full bundle.
  • ReportFinalFiles can be very verbose - it dumps the full content of every generated file. Best used for debugging a specific module, not in production scaffold runs.
  • Enabled by default but quiet - with default options, the sink is enabled but ReportFileCreation and ReportFinalFiles are both false. The only visible behavior is suppressing/showing zero-file renderers.

Carrot