Usage.Logging - JuDelCo/Core GitHub Wiki

Namespace: Ju.Log

Logging

There are a static class named Log in the namespace Ju.Log that provides static methods to generate logs in your application.

These methods are a shorthand to generate events of type LogEvent. This event contains all log data as its log level, the message, an optional context and a Exception reference if provided using the Exception method.

void Assert(bool condition, object msg);
void Debug(object msg);
void Info(object msg);
void Notice(object msg);
void Warning(object msg);
void Error(object msg);
void Exception(object msg, Exception e);

void ToggleContext(bool enable, bool folderTrim = false);

ToggleContext(bool enable, bool folderTrim = false)

You can enable or disable the generation of context for log events using this method (by default is enabled).

In the context there will be info about the file, method and line from where the log was called (this info is filled automatically if enabled).

The path used by the file in the context will be from the folder Assets for Unity projects or the full path from C# native projects.

The last parameter folderTrim allows to trim the folder path to include only the filename of the log caller.

Example

using Ju.Log;

Log.Debug("My log message");
Log.Info(1234.56f);
Log.Exception("There was an error", exception);