BattletechModders / ModTek

Mod system for HBS's PC game BattleTech.
GNU Lesser General Public License v2.1
121 stars 34 forks source link

Allow mods to write to ModTek log #74

Closed Sheep-y closed 5 years ago

Sheep-y commented 6 years ago

In my mod I logs info like settings, patched methods, or errors thrown into a custom log file that is mod specific.

Can we borrow ModTek's Logger? Things like Exception dump is perhaps better logged with ModTek so that all errors are in one place. If you add log level and lazy string format I'll happily migrate all the logging over too!

CptMoore commented 6 years ago

You can use the game's logger to reuse the central logfile. I do it for all my mods.

var logger = HBS.Logging.Logger.GetLogger(Name) logger.Log("hello world");

BATTLETECH\BattleTech_Data\output_log.txt

Sheep-y commented 6 years ago

But does ModTek use it? Isn't it better to keep game log to game and mod to mod log in mod folder?

CptMoore commented 6 years ago

If mod has uncatched exceptions those can appear in game log anyway... So best put everything there to be sure.

See #9 for a related issue.

Sheep-y commented 6 years ago

Ah. I see. So that is where uncaught exception goes. I just catch almost everything so that my mod have a less chance to break the game when it fails (eventually). Yes. Redirecting to game log seems to be a very good idea.

@Mpstark I still wish the Logger can be made public if only to offer more options, but it you don't wish that you may close this ticket.