Skip to content

Another advanced logging framework for Garry's Mod in pure Lua.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE.txt
MIT
LICENSE-MIT.txt
Notifications You must be signed in to change notification settings

GrayWolf64/logging-log4g

Repository Size Commit Activity Issues

Last Commit

Log4g is an advanced logging framework for Garry's Mod.

Currently Work-in-Progress

Con-Commands Usage Desc.
"log4g_mmc" Console Monitoring & Management Console (Component)

Component Src Dir

lua/log4g

How to Add It To Your Project / How to Test?

(not updated) Simply clone this project and extract the project folder into your garrysmod/addons folder. In addition, the code itself is well documented. Then you just have to make sure it loads before your addon, or you can use valid checks:

if Log4g then
   --- This will locate / create a proper LoggerContext named 'Foo' with DefaultConfiguration.
   local ctx = Log4g.API.LoggerContextFactory.GetContext("Foo", true)

   --- This will create a new LoggerConfig named 'Calculator' and it to ctx's Configuration, then set its level to DEBUG.
   local lc = Log4g.Core.Config.LoggerConfig.create("Calculator", ctx:GetConfiguration(), Log4g.Core.Level.GetLevel("TRACE"))

   --- It will add a ConsoleAppender to lc and set its layout to PatternLayout with default settings.
   lc:AddAppender(Log4g.Core.Appender.createConsoleAppender("CalcOutput", Log4g.Core.Layout.PatternLayout.createDefaultLayout("CalcLayout")))

   --- This will create a Logger named 'Calculator' using lc and add it to ctx.
   local logger = Log4g.Core.Logger.create("Calculator", ctx, lc)

   for i = 1, 100 do
      --- Do something with i, and log messages.
      -- Note that when this was written, the logging system isn't finished yet.

      logger:Debug("Calculated: " .. i .. " times.")
   end
end

so that you won't experience errors if your addon is loaded before the logging system. However, your addon won't successfully log any messages until the logging system is loaded.

Documentation

The Log4g Documentation is available here.

Compatibility With Non-GMOD Projects

A lot of functions need to be replaced in order for this to work.

Thanks to Third-party Projects Below

Releases

No releases published

Languages