logging: added multi-level

This commit is contained in:
Harald Milz 2019-04-09 21:03:23 +02:00
parent 212d44cf49
commit 6fbd94d66d
1 changed files with 11 additions and 11 deletions

View File

@ -34,7 +34,7 @@ function gcal_import_worker() {
foreach($terms as $term){
$unique_id = 'gcal_feed_' . $term->name;
if ( empty ( $options[$unique_id] ) || $options[$unique_id] == '' ) {
gcal_error_log ( "INFO: link for event category $term->name is not known; next");
gcal_error_log (INFO, "link for event category $term->name is not known; next");
continue;
}
@ -66,7 +66,7 @@ The update and delete logic goes as follows:
}
// now we process the current feed.
$link = $options[$unique_id];
gcal_error_log ("INFO: now importing event cat $term->name, link $link");
gcal_error_log (INFO, "now importing event cat $term->name, link $link");
gcal_import_do_import($term->name, $link);
// look if there are any published event posts in the current event category which were not posted anew or updated (ie recent == false)
@ -90,7 +90,7 @@ The update and delete logic goes as follows:
foreach( $post_ids as $post_id ) {
$id = $post_id->ID;
wp_trash_post( $id );
gcal_error_log ("Event post $id gelöscht.");
gcal_error_log (INFO, "Event post $id gelöscht.");
}
}
@ -115,7 +115,7 @@ function curl_get_remote($url) {
if ( curl_errno($ch) ) {
// $info = curl_getinfo($ch);
$message = __FUNCTION__ . ": cURL error " . curl_error($ch);
// gcal_error_log ("WARN: $message");
// gcal_error_log (WARN, $message);
curl_close($ch);
throw new \RuntimeException($message);
}
@ -151,7 +151,7 @@ function gcal_import_do_import($category, $link) {
if ($r['DTEND'] < $now) {
continue;
} else {
gcal_error_log ("INFO: processing $summary on $dtstart");
gcal_error_log (INFO, "processing $summary on $dtstart");
}
// The zeitstempel. No idea what it's for, but kal3000 seems to use it.
@ -213,7 +213,7 @@ function gcal_import_do_import($category, $link) {
// create image attachment and associate with new post
$attach = $r['ATTACH'];
$summary = $r['SUMMARY'];
gcal_error_log ("INFO: found attachment $attach for $summary");
gcal_error_log (INFO, "found attachment $attach for $summary");
}
if ( isset ( $r['CLASS'] ) && 'PRIVATE' == $r['CLASS']) {
@ -283,7 +283,7 @@ function gcal_import_do_import($category, $link) {
$post_id = wp_insert_post( $post );
if ( is_wp_error( $post_id ) ) {
$message = $post_id->get_error_message();
gcal_error_log ( "WARN: $message" );
gcal_error_log ( WARN, $message );
} else {
update_post_meta( $post_id, '_edit_last', $user_id );
$now = time();
@ -291,7 +291,7 @@ function gcal_import_do_import($category, $link) {
update_post_meta( $post_id, '_edit_lock', $lock );
// and assign the taxonomy type and event category.
wp_set_object_terms( $post_id, $category, 'termine_type' );
gcal_error_log ("INFO: posted new post $post_id");
gcal_error_log (INFO, "posted new post $post_id");
}
} else {
// good, the post exists already.
@ -305,16 +305,16 @@ function gcal_import_do_import($category, $link) {
$post_id = wp_update_post( $post, false );
// and update the _created field
update_post_meta ( $id, '_gcal_created', $lastmodified );
gcal_error_log ("INFO: updated post $post_id");
gcal_error_log (INFO, "updated post $post_id");
} elseif ( $lastmodified < $created ) {
// iiiiek! A time reversal or a secret time machine! That should not happen!
gcal_error_log ("WARN: post $id last-modified : created $lastmodified < $created ");
gcal_error_log (WARN, "post $id last-modified : created $lastmodified < $created ");
} // else both are equal, and we do nothing except setting recent to true.
update_post_meta ( $id, '_gcal_recent', 'true' );
}
} else {
$file = dirname (__FILE__) . '/get_posts-' . $post->post_name . '.txt';
gcal_error_log ("WARN: hmmm, get_posts() did not return an array. Logging to $file");
gcal_error_log (WARN, "hmmm, get_posts() did not return an array. Logging to $file");
file_put_contents ($file, var_export ($post_ids, TRUE));
}
// and on the next entry.