Setting log level at startup

Post any problems / bugs / issues that are Mylar-related in here.
Post Reply
to0nman
Posts: 4
Joined: Wed Jan 13, 2016 10:31 pm

Setting log level at startup

Post by to0nman »

Is it possible to set the log level at startup?

i.e., --loglevel=ERROR.

When running in a container, the INFO output is fairly verbose. Would like to trim it down.

Thanks
User avatar
evilhero
Site Admin
Posts: 2883
Joined: Sat Apr 20, 2013 3:43 pm
Contact:

Re: Setting log level at startup

Post by evilhero »

Nope, the only available option aside from the default INFO level is the - v option in the cli which enables verbose logging, which is the opposite of what you want.

I'd have to look into it more as it either requires some changes to the logging module or the removal of unneeded logging lines, or both. Right now, the log_level variable in the config.ini isn't being used, but could be used to leverage the default to another level.
to0nman
Posts: 4
Joined: Wed Jan 13, 2016 10:31 pm

Re: Setting log level at startup

Post by to0nman »

Interesting one.

If you accept PR's i might take a look into this one.
It looks like you are already tagging the log level/s (from what I can see), so just adding the ability to control what is recorded should be enough?
(e.g., my log has INFO, ERROR, DEBUG, etc)?
to0nman
Posts: 4
Joined: Wed Jan 13, 2016 10:31 pm

Re: Setting log level at startup

Post by to0nman »

FWIW, it looks like all the plumbing is there (just need to be able to toggle it with the log_level in the config.ini)

E.g., I quickly tested in https://github.com/evilhero/mylar/blob/ ... /logger.py
added ERROR to import

changed INFO to ERROR on logger.setLevel(logging.DEBUG if verbose else logging.ERROR)

Started mylar successfully, and get the behaviour required, i.e., only seeing ERRORS in log output

Will work on how to toggle this and throw a PR up. Your call if you want to merge it in.
User avatar
evilhero
Site Admin
Posts: 2883
Joined: Sat Apr 20, 2013 3:43 pm
Contact:

Re: Setting log level at startup

Post by evilhero »

Yep, course I'll merge & accept the PR's - the only time I really question it if it's something that will change how Mylar does something, and/or it causes problems with some other usage.

Changing the log levels probably should have been included as a base anyways (hindsight being 20/20). I would think since the log_level is already there, just adding a quick check in the logger.py module to see what the value is and assign it should be a relatively simple kind of thing.
Post Reply