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

Log level options #123

Open
ifoss-me opened this issue Jan 13, 2019 · 3 comments · May be fixed by #1006
Open

Log level options #123

ifoss-me opened this issue Jan 13, 2019 · 3 comments · May be fixed by #1006

Comments

@ifoss-me
Copy link

ifoss-me commented Jan 13, 2019

It looks like, though the documentation for icloudpd on GitHub suggest that there's an "error" option for log-level, that it doesn't function and instead outputs debug and info messages as well.

Being a novice coder at best, I'm not quite sure, but when poking around icloud_photos_downloader/icloudpd/logger.py, it looks like there's actually no "error" option.

Could that be causing my problem? If so, should/can that option be added?

@koldinger
Copy link

I ran into this same issue. The problem appears to be that each module gets it's own logger, but the log-level option only sets the log level in the logger used in base.py. As a result, that logger logs at the correct level, but the other modules all don't have the value set correctly.

I have a quick hack level fix that returns the same logger to all the modules, so the logging level is set correctly universally. It's a hack, but it does the trick.

@Kryptonit3-zz
Copy link

Kryptonit3-zz commented Dec 3, 2019

@koldinger what is your fix? I am making a cronjob that will email output. Don't want it being 15 thousand lines long. Only want to see errors. Thanks!

----- edit -----

I decided to make a script that outputs to a log file and then I remove all lines that contain "already exists" and then it sends me an email once a day. Here is what I have for those wondering. You must already have a mail client setup to send outbound mail. I used exim4.

Here are 2 sites that helped me with setting up exim4
http://www.manu-j.com/blog/wordpress-exim4-ubuntu-gmail-smtp/75/
https://www.fyzix.net/index.php?title=Installing_and_Configuring_Exim4_for_Gmail_SMTP_Relay
If using Gmail, generate an app specific password, no need to make your account less secure by changing security to Allow less secure apps: ON. https://myaccount.google.com/apppasswords (Other custom name)

Script installed at /opt/icloud_photos_downloader
My custom script directory at /opt/icloud_photos_downloader_scripts

/opt/icloud_photos_downloader_scripts/cron_jesse.sh contents

#!/usr/bin/env bash

# start a timer
start=$(date +%s);

# clear previous run from log file
sudo cp /dev/null /opt/icloud_photos_downloader_scripts/backup_jesse.log

# run script to grab all photos/videos and output to log file
sudo python /opt/icloud_photos_downloader/icloudpd.py --username [email protected] --password icloudpassword --directory /mnt/media/icloud_backups/jesse/ --size original --live-photo-size original --smtp-host smtp.gmail.com --smtp-port 587 --smtp-username [email protected] --smtp-password mypassword --notification-email [email protected] --no-progress-bar --log-level error > /opt/icloud_photos_downloader_scripts/backup_jesse.log

# remove the lines that output a file already exists so we only see what new files were added
sudo sed -i "/\b\(already exists\)\b/d" /opt/icloud_photos_downloader_scripts/backup_jesse.log

# stop timer and calculate runtime
end=$(date +%s);
runtime=$((end-start));
hours=$((runtime / 3600));
minutes=$(( (runtime % 3600) / 60 ));
seconds=$(( (runtime % 3600) % 60 ));
duration="Runtime: $hours:$minutes:$seconds (hh:mm:ss)"

# prepend the log file with the runtime so we see it first in the email
sudo sed -i "1s;^;$duration\n;" /opt/icloud_photos_downloader_scripts/backup_jesse.log

# send the email
sudo mail -s 'iCloud Backup Report - Jesse' [email protected] < /opt/icloud_photos_downloader_scripts/backup_jesse.log

crontab contents - will run once a day at midnight
0 0 * * * /opt/icloud_photos_downloader_scripts/cron_jesse.sh

@menkej
Copy link
Collaborator

menkej commented Oct 29, 2020

Currently the script is not logging "ERRORS" in any separate way. What exactly would be your expectation which messages should come out an which not? Maybe we could put something together? Or are you already happy with @Kryptonit3-zz 's script solution?

@sdebruyn sdebruyn linked a pull request Nov 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants