Onsharp
  • What is Onsharp?
  • Changelog
  • Onsharp Environment
    • Onsharp Runtime Environment
    • Installation
    • Configuration
  • Basic Usage
    • Preparation
    • Create a Basic Plugin
    • Concept of Entry Points
    • Create Commands
    • The EventAPI of Onsharp
    • Configs and DataStorage
    • Logging
    • Debugging
  • Advance Usage
    • Auto Updater
    • Overriding Entity Factories
    • Interop of LUA and vice versa
    • Entity Pool Refreshing
    • Create Console Commands
    • Providing LUA packages
  • Modules
    • Lazy Mover
    • I18n
Powered by GitBook
On this page
  • The Logger
  • String Formatting
  • Debug Mode

Was this helpful?

  1. Basic Usage

Logging

On this page, we will explain you, how to log your plugin with the built in logging system.

The Logger

Every plugin has its own logger. The logger gets created with the plugin id or the plugin name as prefix and can be accessed by the plugin main class.

The logger has 6 logging levels:

  1. Debug: Only available if debugging mode is enabled

  2. Info: The normal message

  3. Warn: If you want to warn the user

  4. Fatal: An error which is not occurring because of an C# exception

  5. Error: An error which is occurring because of an C# exception

  6. Verbose

The logger will automically log the message to the console as well as to a logging file in the logs folder for the given plugin.

String Formatting

The logging system has its own built in string format. Just use the logging methods and pass your arguments. The message than can contain placeholders with curly brackets like {PLACEHOLDER}.

Debug Mode

To enable the debug mode for plugins, you have two ways: Using the logger's setter or the plugin meta.

  1. Plugin Meta: Just set IsDebug to true in the PluginMeta attribute

  2. Logger's Setter: Just call Logger.SetDebug(true/false) to enable or disable the debugging

When the logger is not in debug mode, debug message won't be printed nor saved to the log files.

PreviousConfigs and DataStorageNextDebugging

Last updated 4 years ago

Was this helpful?