logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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 through the singleton loader's ownership rule — so the sink settings are project-wide singletons resolved by that same rule (LoggingSinkResolution): two project-owned candidates are a conflict the run reports and never writes through, not a reason to create another. 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
    object
    LoggingProfileCreator
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Logging.Infrastructure.Editor.Builder
    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
    Type Description
    string

    ConsoleSettingsFileNameFallback

    Fallback file name for a brand-new console sink asset.

    Declaration
    public const string ConsoleSettingsFileNameFallback = "UnityConsoleLogSettings"
    Field Value
    Type Description
    string

    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
    Type Description
    string

    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
    Type Description
    string

    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
    Type Description
    string

    FileLoggerKey

    Declaration
    public const string FileLoggerKey = "file"
    Field Value
    Type Description
    string

    FileSettingsFileNameFallback

    Fallback file name for a brand-new file sink asset.

    Declaration
    public const string FileSettingsFileNameFallback = "UnityFileLogSettings"
    Field Value
    Type Description
    string

    ProfileFileNameFallback

    Fallback file name for a brand-new profile asset, and ProfileId's own default value.

    Declaration
    public const string ProfileFileNameFallback = "LogProfile"
    Field Value
    Type Description
    string

    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
    Type Description
    string

    StructuredSettingsFileNameFallback

    Fallback file name for a brand-new structured sink asset.

    Declaration
    public const string StructuredSettingsFileNameFallback = "UnityStructuredLogSettings"
    Field Value
    Type Description
    string

    Methods

    Create(Input)

    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
    Type Name Description
    LoggingProfileCreator.Input input
    Returns
    Type Description
    LoggingProfileCreator.Result

    DescribeFileLogFileNameProblem(string)

    Mirrors UnityFileLogService.GetLogFilePath: the runtime appends this value verbatim to the user data directory, so it must be a bare file name — not a path, and never able to escape the directory it is written into. Null when it is one. Shared with the window's own field hint.

    Declaration
    public static string DescribeFileLogFileNameProblem(string fileLogFileName)
    Parameters
    Type Name Description
    string fileLogFileName
    Returns
    Type Description
    string

    ResolveConsoleSettingsContext(string)

    Exposed so CreateLoggingProfileWindow can auto-detect the project-wide console sink singleton.

    Declaration
    public static SettingsAssetAuthoring.SettingsResolution<UnityConsoleLogSettings> ResolveConsoleSettingsContext(string explicitConsoleSettingsAssetPath = "")
    Parameters
    Type Name Description
    string explicitConsoleSettingsAssetPath
    Returns
    Type Description
    SettingsResolution<UnityConsoleLogSettings>

    ResolveFileSettingsContext(string)

    Exposed so CreateLoggingProfileWindow can auto-detect the project-wide file sink singleton.

    Declaration
    public static SettingsAssetAuthoring.SettingsResolution<UnityFileLogSettings> ResolveFileSettingsContext(string explicitFileSettingsAssetPath = "")
    Parameters
    Type Name Description
    string explicitFileSettingsAssetPath
    Returns
    Type Description
    SettingsResolution<UnityFileLogSettings>

    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
    Type Name Description
    string folder
    string profileId
    Returns
    Type Description
    SettingsResolution<UnityLogProfile>

    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
    Type Description
    SettingsResolution<UnityStructuredLogSettings>

    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
    Type Name Description
    string defaultLoggerKey
    DefaultLoggerChoice choice
    Returns
    Type Description
    bool

    Validate(Input)

    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
    Type Name Description
    LoggingProfileCreator.Input input
    Returns
    Type Description
    SerenityCreationValidationResult
    In this article
    © 2026 Serenity. All Rights Reserved