[Gambas-user] gb.logging API change

Sebastian Kulesz sebikul at ...626...
Mon Dec 29 05:22:07 CET 2014


So, i have changed the API again. Now, each logger has an associated array
of handlers, each of which takes care of storing the data in a specific
way. Right now, the component only includes a console handler to output
logs to stdout or stderr. And a file handler to output logs to files.
Each logger can have an arbitrary amount of loggers, and they even can be
shared across loggers.
This way a several loggers can output to the same file by sharing a
handler, or a logger can output to several files, all depending on the
logging level.

Take a look at the following example:
<---------
  Dim aHandler, bHandler As LogHandler

  Dim bLogger As Logger

  aHandler = New ConsoleHandler(ConsoleHandler.STDOUT)
  bHandler = New FileHandler("~/Desktop")

  bLogger = New Logger(Null, aHandler)

  bLogger.Begin()

  bLogger.Log("This goes to the stdout stream")

  bLogger.addHandler(bHandler)
  bHandler.Open

  bLogger.Log("I can read this in the console or at a file stored in my
Desktop folder.")

  Logger.Log("There is no need to use handlers. You can use the Logger
anonymously.")
---------->

bLogger outputs to 2 locations simultaneously. If you want, both handlers
could use a different level of severity ;)

I will be adding some more handlers in the following days.

Enjoy!

On Tue, Dec 17, 2013 at 12:48 AM, Sebastian Kulesz <sebikul at ...626...>
wrote:

> My bad. It should be fixed in rev #6010. Please let me know!
>
>
> On Mon, Dec 16, 2013 at 9:55 PM, Bruce <bbruen at ...2308...> wrote:
>
>> Sebastian,
>>
>> With the new version the $(callLocation) is always returning the same
>> location ("Logger._call.95").
>>
>> I stuck some debug in the Formatter to print the stack backtrace, here's
>> what I get when using the Logger from "outside":
>>
>>         Formatter.GetCallLocation.10: Formatter.GetCallLocation.10
>>         Formatter._call.45
>>         Logger.Log.87
>>         Logger._call.95
>>         Application._init.57
>>
>> i.e. I think you should be using System.Backtrace[4] instead of [3]
>>
>> hth
>> Bruce
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Rapidly troubleshoot problems before they affect your business. Most IT
>> organizations don't have a clear picture of how application performance
>> affects their revenue. With AppDynamics, you get 100% visibility into your
>> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
>> Pro!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>



More information about the User mailing list