Skip to content

Commit ffbaa88

Browse files
committed
Archival package creation: add ability to log errors to a file.
1 parent b512bd4 commit ffbaa88

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,22 @@ Note: if wanting to test [leaf-isle-bagger] and [isle-bagger] locally
205205

206206
See the following as an alternative to specifying an OCI image registry and tag in the Dockerfile: <https://docs.docker.com/build/bake/reference/>. As an example, see [isle-buildkit] `docker-bake.hcl`.
207207

208+
## FAQ
209+
210+
### Debugging from the audit log:
211+
212+
``` bash
213+
tmp=$(grep x /data/leaf-bagger/_leaf_bagger_audit_2025-01-03T_15-08-06.csv | head -15 | cut -d ',' -f1 | tr '\n' ' ')
214+
for item in $tmp; do
215+
./venv/bin/python3 leaf-bagger.py \
216+
--server ${BAGGER_DRUPAL_URL} \
217+
--output /tmp/z.csv \
218+
--force_single_node ${item} \
219+
--container cwrc-test \
220+
;
221+
done
222+
```
223+
208224
---
209225

210226
[isle-bagger]: https://github.com/cwrc/isle-bagger

rootfs/etc/s6-overlay/scripts/bagger-setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function setup_cron {
77
cat <<EOF | crontab -u nginx -
88
# min hour day month weekday command
99
# ${BAGGER_CROND_SCHEDULE} cd ${BAGGER_APP_DIR} && ./bin/console app:islandora_bagger:process_queue --queue=${BAGGER_QUEUE_PATH}
10-
${BAGGER_CROND_SCHEDULE} cd ${LEAF_BAGGER_APP_DIR} && ./venv/bin/python3 leaf-bagger.py --server ${BAGGER_DRUPAL_URL} --output ${LEAF_BAGGER_OUTPUT_DIR}/_leaf_bagger_\$(date +"%Y-%m-%dT_%H-%M-%S").csv --container ${OS_CONTAINER} --date \$(date -d "@\$((\$(date +%s) - ${LEAF_BAGGER_CROND_DATE_WINDOW}))" +"%Y-%m-%d") && ./venv/bin/python3 leaf-bagger-audit.py --server ${BAGGER_DRUPAL_URL} --output ${LEAF_BAGGER_AUDIT_OUTPUT_DIR}/_leaf_bagger_audit_\$(date +"%Y-%m-%dT_%H-%M-%S").csv --container ${OS_CONTAINER}
10+
${BAGGER_CROND_SCHEDULE} cd ${LEAF_BAGGER_APP_DIR} && ./venv/bin/python3 leaf-bagger.py --server ${BAGGER_DRUPAL_URL} --output ${LEAF_BAGGER_OUTPUT_DIR}/_leaf_bagger_\$(date +"%Y-%m-%dT_%H-%M-%S").csv --container ${OS_CONTAINER} --date \$(date -d "@\$((\$(date +%s) - ${LEAF_BAGGER_CROND_DATE_WINDOW}))" +"%Y-%m-%d") --error_log ${LEAF_BAGGER_OUTPUT_DIR}/_leaf_bagger_\$(date +"%Y-%m-%dT_%H-%M-%S")_error.log; ./venv/bin/python3 leaf-bagger-audit.py --server ${BAGGER_DRUPAL_URL} --output ${LEAF_BAGGER_AUDIT_OUTPUT_DIR}/_leaf_bagger_audit_\$(date +"%Y-%m-%dT_%H-%M-%S").csv --container ${OS_CONTAINER};
1111
EOF
1212
fi
1313
}

rootfs/var/www/leaf-isle-bagger/drupal/utilities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def create_aip(node_list, bagger_app_path):
125125
stderr=subprocess.STDOUT,
126126
check=True,
127127
cwd=bagger_app_path,
128+
text=True,
128129
)
129130
except subprocess.CalledProcessError as e:
130131
logging.error(f"{e}")

rootfs/var/www/leaf-isle-bagger/leaf-bagger.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def parse_args():
2828
parser.add_argument(
2929
"--output", required=True, help="Location to store CSV output file."
3030
)
31+
parser.add_argument(
32+
"--error_log",
33+
required=False,
34+
default=None,
35+
help="Location to store error logs.",
36+
)
3137
parser.add_argument(
3238
"--date", required=False, help="Items changed after the given date."
3339
)
@@ -117,8 +123,14 @@ def main():
117123

118124
args = parse_args()
119125

120-
logging.basicConfig(level=args.logging_level)
121-
logging.getLogger('swiftclient').setLevel(logging.CRITICAL)
126+
# Create logging handlers
127+
logging_handlers = [logging.StreamHandler()]
128+
if args.error_log is not None:
129+
logging_handlers.append(logging.FileHandler(args.error_log))
130+
131+
# Config Logging
132+
logging.basicConfig(level=args.logging_level, handers=logging_handlers)
133+
logging.getLogger("swiftclient").setLevel(logging.CRITICAL)
122134

123135
username, password = drupalUtilities.get_drupal_credentials()
124136

0 commit comments

Comments
 (0)