Table of Contents

Namespace ToSic.Lib.Logging

The EAV system has a powerful internal logging system. It's the backbone to Insights.

This is where it resides - usually you don't want to know about it ;).

If you do, here a short conceptual background:

  • Any object can have a property - usually called Log which is an ILog .
    Using this the object can call the Log.Add(...) to add messages. Many other commands help in various scenarios.

  • The real power comes from chaining these - because each logger can know what parent-logger it reports to.
    This allows us to reproduce the chain of events in the original code, because you can track where
    loggers were made, and how they relate.

  • The really amazing bit is that the logger will also pick up the class names, code-file names and line of code where it was logged 😎.

  • Most objects which use the Log, implement the IHasLog, often by inheriting
    ToSic.Lib.Logging.HasLog which automates things when initializing - like the chaining of the Loggers.

Classes

CodeRef

Reference to source code. It contains the path to the file, the method name and the line in the code.

This is used to track the exact location in the code where a log was added/created.

IHasLogExtensions

Extension to objects having a Log, to connect them to parent logs.

ILogCallExtensions

Extensions for ILogCall objects which don't need to return a value.

ILogExtensions

Various extensions for ILog objects to add logs. They are all implemented as extension methods, so that they will not fail even if the log object is null.

ILog_Actions

Extension methods for Actions (functions which don't return a value).

ILog_Add

Various extensions for ILog objects to add logs. They are all implemented as extension methods, so that they will not fail even if the log object is null.

ILog_Properties

Extension methods for property getters and setters.

LogConstants

Interfaces

ICanDebug

Trivial interface just to ensure that we have debug on/off consistent

ICanDump

Interface to mark classes which can dump their state into the log as a string.

IHasLog

Objects which can log their activity, and share their log with other objects in the chain to produce extensive internal logging.

ILog

A logger with special capabilities. It can take log messages, and chain itself to other loggers.
If chained, it can broadcast the messages to the other loggers from that time forward. Basically this is the backbone of Insights.

To add messages/logs of all kinds you must use null-safe extension methods. It will require you to add the namespace ToSic.Lib.Logging.

ILogCall

A log object used to log the activity of a specific function call. It is usually created in the beginning of the call and closed on various return calls or at the end of the function.

Note that most of the methods used to complete a call are extension methods.

ILogCall<T>

A mini logger for a function call, which should be closed using a form of Return(...) when the function completes.

ILogStore

Interface to add ILogs to the log storage.