We prefer xlog(L_ERROR) in most cases because it prefixes the program name to error messages. The usual exceptions are a command's usage message, and output that must occur before the xlog_open() call.
Signed-off-by: Chuck Lever <[email protected]> --- src/nfsref/nfsref.c | 6 +++--- src/nfsref/remove.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/nfsref/nfsref.c b/src/nfsref/nfsref.c index ef7c5a7..78cda51 100644 --- a/src/nfsref/nfsref.c +++ b/src/nfsref/nfsref.c @@ -139,7 +139,7 @@ main(int argc, char **argv) else if (strcmp(optarg, "nfs-fedfs") == 0) type = NFSREF_TYPE_NFS_FEDFS; else { - fprintf(stderr, + xlog(L_ERROR, "Unrecognized junction type: %s", optarg); exit(EXIT_FAILURE); @@ -156,7 +156,7 @@ main(int argc, char **argv) } if (!help && geteuid() != 0) { - fprintf(stderr, "Root permission is required\n"); + xlog(L_ERROR, "Root permission is required"); goto out; } @@ -169,7 +169,7 @@ main(int argc, char **argv) goto out; } if (argc < optind + 3) { - fprintf(stderr, "Not enough positional parameters\n"); + xlog(L_ERROR, "Not enough positional parameters"); nfsref_usage(progname); goto out; } diff --git a/src/nfsref/remove.c b/src/nfsref/remove.c index 7bee9de..8f2f5d0 100644 --- a/src/nfsref/remove.c +++ b/src/nfsref/remove.c @@ -165,13 +165,13 @@ nfsref_remove_delete_fsn(const char *junct_path) if (binddn == NULL) binddn = (char *)nsdb_default_binddn(host); if (binddn == NULL) { - fprintf(stderr, "No NDSB bind DN was specified\n"); + xlog(L_ERROR, "No NDSB bind DN was specified"); goto out_free; } if (nce == NULL) nce = (char *)nsdb_default_nce(host); if (nce == NULL) { - fprintf(stderr, "No NCE was specified\n"); + xlog(L_ERROR, "No NCE was specified"); goto out_free; } @@ -180,20 +180,20 @@ nfsref_remove_delete_fsn(const char *junct_path) case FEDFS_OK: break; case FEDFS_ERR_NSDB_CONN: - fprintf(stderr, "Failed to connect to NSDB %s:%u\n", + xlog(L_ERROR, "Failed to connect to NSDB %s:%u", nsdb_hostname(host), nsdb_port(host)); goto out_free; case FEDFS_ERR_NSDB_AUTH: - fprintf(stderr, "Failed to authenticate to NSDB %s:%u\n", + xlog(L_ERROR, "Failed to authenticate to NSDB %s:%u", nsdb_hostname(host), nsdb_port(host)); goto out_free; case FEDFS_ERR_NSDB_LDAP_VAL: - fprintf(stderr, "Failed to authenticate to NSDB %s:%u: %s\n", + xlog(L_ERROR, "Failed to authenticate to NSDB %s:%u: %s", nsdb_hostname(host), nsdb_port(host), ldap_err2string(ldap_err)); goto out_free; default: - fprintf(stderr, "Failed to bind to NSDB %s:%u: %s\n", + xlog(L_ERROR, "Failed to bind to NSDB %s:%u: %s", nsdb_hostname(host), nsdb_port(host), nsdb_display_fedfsstatus(retval)); goto out_free; @@ -207,26 +207,26 @@ nfsref_remove_delete_fsn(const char *junct_path) break; case FEDFS_ERR_NSDB_NONCE: if (nce == NULL) - fprintf(stderr, "NSDB %s:%u has no NCE\n", + xlog(L_ERROR, "NSDB %s:%u has no NCE", nsdb_hostname(host), nsdb_port(host)); else - fprintf(stderr, "NCE %s does not exist\n", nce); + xlog(L_ERROR, "NCE %s does not exist", nce); break; case FEDFS_ERR_NSDB_NOFSN: - fprintf(stderr, "NSDB %s:%u has no such FSN %s\n", + xlog(L_ERROR, "NSDB %s:%u has no such FSN %s", nsdb_hostname(host), nsdb_port(host), fsn_uuid); break; case FEDFS_ERR_NSDB_NOFSL: - fprintf(stderr, "FSN %s still has FSL entries\n", fsn_uuid); + xlog(L_ERROR, "FSN %s still has FSL entries", fsn_uuid); break; case FEDFS_ERR_NSDB_LDAP_VAL: /* XXX: "Operation not allowed on non-leaf" means * this FSN still has children FSLs. */ - fprintf(stderr, "Failed to delete FSN %s: %s\n", + xlog(L_ERROR, "Failed to delete FSN %s: %s", fsn_uuid, ldap_err2string(ldap_err)); break; default: - fprintf(stderr, "Failed to delete FSN %s: %s\n", + xlog(L_ERROR, "Failed to delete FSN %s: %s", fsn_uuid, nsdb_display_fedfsstatus(retval)); } _______________________________________________ fedfs-utils-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/fedfs-utils-devel
