Giter VIP home page Giter VIP logo

wunitylogger's Introduction

WPLogger

Introduction

Well's Personal Logger is a better logging system for Unity in C#.

I am sure other logging project can be better but I had fun making my own.

This project has two main features :

  • Remove logs in build for better performances
  • Tag to show/hide any logs.

Secondary features :

  • Save logs to file
  • Enable/Disable log to unity console (for performance)
  • Enable/Disable log history (for performance)
  • Enable/Disable display time or tags in log
  • Event on log and error
  • Option to keep logs in build
  • Debug UI Prefab to display logs in scene (Usefull when in build)

Log stripping

When building for release, Debug.Log are not usefull but stay in the codebase. A better way of handling this is to remove them at compilation.

The tool use the conditionnal attribute, available in C#, to keep logs only when conditions are met.

The 3 conditions to keep logs in code are :

  • Unity Editor
  • Development build
  • "WPLOG" exist as a preprocessor directives (Use editor window)

Error logs are never removed.

Editor Window

Multiple options are available on the unity editor window on the top bar menu Tools -> WPLogger

Using the editor will ask you to select a folder to place required data files.

If you want to active the WPLOG preprocessor directive using the editor tool, it will create a csc.rsp file in Assets folder.

Tags

Tags are usefull when the project get bigger and contain lot of differents modules and tools.

Each tool and modules should add a tag unique to them when logging, this allow to only display logs that are currently needed for working.

A tag can be any string, but they are case sensitives and only some default tags are enabled.

The special tag "F" allow to force display the log even if his tags are disabled.

Example:

WPLogger.Log("My message", WPTags.TESTTag, "anotherTag");

Managing active tags at runtime:

void SetTagActive(string tag)   // Allow a new tag to be logged

void SetTagDisabled(string tag) // Disable a tag from any new log

bool IsTagActive(string tag)    // Check if the tag is active

Error logs are not affected by tags but you can use tag for better clarity.

Log

The function Log used to display log with the tag system

Trigger "OnLogged" event.

//Definition
void Log(string message, params string[] tags)

//Example
string varMyTag = "TEST"
WPLogger.Log(message);
WPLogger.Log(message, tag1, tag2);
WPLogger.Log("My message concerning AI", "AI", "NAVMESH", "ENNEMIES", varMyTag);

FLog

Fast&Force log doesn't implement the tag, events, history, time functions.

It only log to Unity console for better performance.

This function is still stripped from build.

//Definition
void Flog(string message)

//Example
WPLogger.Flog("Log message that can't use tags");

LogError

The function Error is used to display errors with the tag system

Errors are not stripped from build and are always displayed even when all tags are disabled.

Trigger "OnErrorLogged" event.

//Definition
void Error(string message, params string[] tags)

//Example
string varMyTag = "HelloTag"
WPLogger.Error("Error !", varMyTag, "OtherTag");

Debug UI

A prefab to display Wplogger logs in scenes. It allow easier understanding of logs and errors in builds

F12 to toggle display

wunitylogger's People

Contributors

w3llgun avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.