Class LoggingProfileCreator
Generates (or updates) the assets the Logging aggregate needs to boot with a working default logger:
the UnityConsoleLogSettings sink, the UnityFileLogSettings sink, the
optional UnityStructuredLogSettings sink (plus its shared backend asset, authored through
the same StructuredBackendAuthoringFactory engine GameSave/GameProgress use), and a
UnityLogProfile wired to whichever sink(s) are enabled. Today the only tool that creates
any of these is the one-shot Initialize Serenity wizard (console/file settings only, via generic recipe assets) —
this is the first dedicated creation wizard for the aggregate, and the first ever for
UnityLogProfile, which otherwise has no authoring tool at all.
Resolution differs per asset, matching how the runtime actually discovers each one:
UnityConsoleLogInstaller/Serenity.EventDispatcher.Installation.Installers.UnityFileLogInstaller
each fall back to UnityAssetUtils.LoadAllFromAnyBlocking<T> over the module:logging
label and use the first match — so the two sink settings are project-wide singletons (ambiguity is a
warning, never an error), resolved the same way Serenity.SystemConfiguration.Infrastructure.Editor.Builder.SystemConfigurationSettingsCreator
resolves its own settings asset, through the shared SettingsAssetAuthoring engine.
UnityStructuredLogSettings resolves the SAME way while the composition root's
StructuredLogSettings list is empty — UnitySerenityInstaller.InstallStructuredLogService
then runs the same zero-config Addressables-label pass — so this wizard authors it with the identical
singleton-resolution/ambiguity-warning behavior as Console/File, even though the runtime also supports
N structured instances once the list is populated by hand.
UnityLogProfile is different: UnitySerenityInstaller.LogProfile is assigned directly
on the composition root, and the shipped project already carries two of them side by side
(EditorLogProfile, StandaloneLogProfile) — so a profile resolves by Id
within OutputFolderPath, the same by-Id-in-folder pattern
Serenity.AssetPrefetcher.Infrastructure.Editor.Builder.PrefetchPolicyCreator uses for its
N PrefetchPolicyProfile rows.
DefaultLoggerKey uses the literal "console"/"file"/"structured"(:"{Id}") keys, not an
assembly-qualified type name — even though the two profiles shipped with the project (EditorLogProfile,
StandaloneLogProfile) use AQN strings. UnitySerenityInstaller.GetLogServiceFromKeyOrTypeName
recognizes all of them directly, but a literal key survives a class rename or namespace move that would
silently break an AQN-based profile; a wizard-authored profile should not carry a value that can bit-rot.
CreateLoggingProfileWindow only collects input and renders results; every asset mutation
lives here.
Inheritance
LoggingProfileCreator
Assembly: Serenity.UnityLogging.Infrastructure.Editor.dll
Syntax
public static class LoggingProfileCreator
Fields
ConsoleLoggerKey
The literal keys UnitySerenityInstaller.GetLogServiceFromKeyOrTypeName
recognizes directly — see the type doc for why this wizard prefers them over an AQN string.
Declaration
public const string ConsoleLoggerKey = "console"
Field Value
ConsoleSettingsFileNameFallback
Fallback file name for a brand-new console sink asset.
Declaration
public const string ConsoleSettingsFileNameFallback = "UnityConsoleLogSettings"
Field Value
DefaultOutputFolder
Folder a brand-new asset chain is created under when the caller names none.
Declaration
public const string DefaultOutputFolder = "Assets/Game/Media/Logging"
Field Value
DefaultStructuredLocalFileDirectoryName
Default LocalFile backend directory name for a structured sink's backend, matching
StructuredLogBackendFactory's own runtime fallback directory.
Declaration
public const string DefaultStructuredLocalFileDirectoryName = "logs"
Field Value
DefaultStructuredSqliteDatabaseFileName
Default Sqlite backend database file name for a structured sink's backend, matching
StructuredLogBackendFactory's own runtime fallback database file.
Declaration
public const string DefaultStructuredSqliteDatabaseFileName = "logs.db"
Field Value
FileLoggerKey
Declaration
public const string FileLoggerKey = "file"
Field Value
FileSettingsFileNameFallback
Fallback file name for a brand-new file sink asset.
Declaration
public const string FileSettingsFileNameFallback = "UnityFileLogSettings"
Field Value
ProfileFileNameFallback
Fallback file name for a brand-new profile asset, and ProfileId's own default value.
Declaration
public const string ProfileFileNameFallback = "LogProfile"
Field Value
StructuredLoggerKey
The bare structured logger key — only unambiguous while exactly one structured sink
instance is installed. See StructuredLogSinkResolver for the multi-instance rules
and the structured:{Id} instance-key syntax this wizard also authors via
StructuredSettingsId.
Declaration
public const string StructuredLoggerKey = "structured"
Field Value
StructuredSettingsFileNameFallback
Fallback file name for a brand-new structured sink asset.
Declaration
public const string StructuredSettingsFileNameFallback = "UnityStructuredLogSettings"
Field Value
Methods
Validates the request, then resolves-or-creates the console sink, the file sink, the structured sink
(and its backend), and the profile, applying every field. On any failure every mutation is rolled
back through the transaction's existing-asset restores: any already-existing asset that was being
edited has its pre-call field values restored first — undoing any reference it may hold to an asset
this same call just created — and only then are created assets/folders deleted and their
Addressables entries removed. Putting a replaced structured backend back at its own path is part of
the same rollback — see Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction.TrackReplacedAsset(System.String,System.String).
Declaration
public static LoggingProfileCreator.Result Create(LoggingProfileCreator.Input input)
Parameters
Returns
ResolveConsoleSettingsContext(string)
Declaration
public static SettingsAssetAuthoring.SettingsResolution<UnityConsoleLogSettings> ResolveConsoleSettingsContext(string explicitConsoleSettingsAssetPath = "")
Parameters
| Type |
Name |
Description |
| string |
explicitConsoleSettingsAssetPath |
|
Returns
ResolveFileSettingsContext(string)
Declaration
public static SettingsAssetAuthoring.SettingsResolution<UnityFileLogSettings> ResolveFileSettingsContext(string explicitFileSettingsAssetPath = "")
Parameters
| Type |
Name |
Description |
| string |
explicitFileSettingsAssetPath |
|
Returns
ResolveProfileContext(string, string)
Exposed so CreateLoggingProfileWindow can auto-detect the profile this run
would resolve-or-create, mirroring the by-Id-in-folder half of Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.ValidateProfileResolution(Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.Input,Serenity.Global.Infrastructure.Editor.SerenityCreationValidationResult).
Unlike the three sink wrappers above, a by-Id-in-folder lookup has no "ambiguous — multiple assets"
outcome to report: Serenity.Global.Infrastructure.Editor.SerenityAssetIdLookup.FindIdMatchesInFolder``1(System.String,System.String) returns at
most one exact match by construction, so MultipleFoundPaths
is always null here. A different profile elsewhere in the project sharing this Id is a separate,
non-blocking concern Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.ValidateProfileResolution(Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.Input,Serenity.Global.Infrastructure.Editor.SerenityCreationValidationResult) already warns about — it is not an
ambiguity about which asset THIS run edits.
Declaration
public static SettingsAssetAuthoring.SettingsResolution<UnityLogProfile> ResolveProfileContext(string folder, string profileId)
Parameters
Returns
ResolveStructuredSettingsContext(string)
Exposed so CreateLoggingProfileWindow can auto-detect the project-wide
structured sink singleton — retires that window's own hand-rolled ExistingStructuredSettings,
which used a bare UnityEditor.AssetDatabase.FindAssets(System.String) count check and silently treated
more than one match as "none found" instead of surfacing the ambiguity.
Declaration
public static SettingsAssetAuthoring.SettingsResolution<UnityStructuredLogSettings> ResolveStructuredSettingsContext(string explicitStructuredSettingsAssetPath = "")
Parameters
| Type |
Name |
Description |
| string |
explicitStructuredSettingsAssetPath |
|
Returns
TryMapDefaultLoggerKeyToChoice(string, out DefaultLoggerChoice)
Inverse of Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.ResolveDefaultLoggerKey(Serenity.Logging.Infrastructure.Editor.Builder.LoggingProfileCreator.Input): maps an existing profile's persisted
DefaultLoggerKey back onto this wizard's LoggingProfileCreator.DefaultLoggerChoice,
so CreateLoggingProfileWindow can seed its Default Logger selection from a resolved
profile instead of always defaulting to Console. Returns false for
any key this wizard did not itself author — an assembly-qualified type name (the two profiles shipped
with the project use one) or any other custom value — because none of those map onto a
LoggingProfileCreator.DefaultLoggerChoice without guessing; the caller keeps whatever choice is already
selected and warns that saving overwrites the profile's real key with a wizard literal.
Declaration
public static bool TryMapDefaultLoggerKeyToChoice(string defaultLoggerKey, out LoggingProfileCreator.DefaultLoggerChoice choice)
Parameters
Returns
Validates the request: a non-empty ProfileId, at least one sink enabled (a
profile with every sink disabled resolves to no logger at all at boot), the chosen
DefaultLogger must be one of the enabled sinks, the file sink's
FileLogFileName must be a bare, valid file name (never a path — it is appended
directly to IPathService.GetUserDataDir()), a well-formed output folder, and the same
resolve-or-edit ambiguity/overwrite warnings Create(Input) would act on.
Declaration
public static SerenityCreationValidationResult Validate(LoggingProfileCreator.Input input)
Parameters
Returns
| Type |
Description |
| SerenityCreationValidationResult |
|