Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable logging? #14

Open
B45i opened this issue Oct 15, 2022 · 4 comments
Open

Disable logging? #14

B45i opened this issue Oct 15, 2022 · 4 comments

Comments

@B45i
Copy link

B45i commented Oct 15, 2022

I dont want to have logging in my server, is ther any way to do that?

@shinkuan
Copy link

shinkuan commented Nov 13, 2022

I believe you can achieve this by editing the variables at

_log_truncate_at = 11 * 1024

@GeoffMurray
Copy link

GeoffMurray commented Dec 4, 2022

I think maybe you can also just make this call in your main execution code:

logging.set_truncate_thresholds(truncate_at, truncate_to)

Maybe set to 0,0 ?

@lixas
Copy link

lixas commented Dec 13, 2022

what Ive done, its quite simple:

Declare variable at top of logging.py file

log_file = "log.txt"
_WRITE_FILE = False    # new variable to control logging to file

and change log function to following:

def log(level, text):
    global _WRITE_FILE    # access variable from global scope
    datetime = datetime_string()
    log_entry = "{0} [{1:8} /{2:>4}kB] {3}".format(datetime, level, round(gc.mem_free() / 1024), text)
    print(log_entry)
    if _WRITE_FILE:    # this flag control, is it neededto write into file
        with open(log_file, "a") as logfile:
            logfile.write(log_entry + '\n')

    if _log_truncate_at and file_size(log_file) > _log_truncate_at:
        truncate(log_file, _log_truncate_to)

NOTE: take care of spaces to match your file, as i've changed from 2 spaces to 4

@Nikorasu
Copy link

I had to disable logging on one of my projects, cause for some reason log entries were ending up in a separate file I was working with called messages.txt.. The log entries were randomly appearing in that file, overriding what was in there.. And I haven't been able to figure out what intentionally replicates it yet, to make a proper report.

But I think I managed to disable logging entirely, by simply doing this:

from phew.logging import disable_logging_types, LOG_ALL
disable_logging_types(LOG_ALL)

(Using the latest version from the repo.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants