Rewrote logfile handling from scratch

This commit is contained in:
jsteube
2016-09-23 21:41:05 +02:00
parent 7d9ff152b0
commit 0a330d4335
8 changed files with 246 additions and 227 deletions
+3
View File
@@ -19,7 +19,10 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, user_options_t *user_options, char *hash_or_file);
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, user_options_t *user_options);
int hashes_init_stage3 (hashes_t *hashes, hashconfig_t *hashconfig, user_options_t *user_options);
void hashes_destroy (hashes_t *hashes);
void hashes_logger (const hashes_t *hashes, const logfile_ctx_t *logfile_ctx);
#endif // _HASH_MANAGEMENT_H
+18 -15
View File
@@ -13,29 +13,32 @@
// logfile_append() checks for logfile_disable internally to make it easier from here
#define logfile_top_msg(msg) logfile_append (user_options, "%s\t%s", data.topid, (msg));
#define logfile_sub_msg(msg) logfile_append (user_options, "%s\t%s\t%s", data.topid, data.subid, (msg));
#define logfile_top_var_uint64(var,val) logfile_append (user_options, "%s\t%s\t%" PRIu64 "", data.topid, (var), (val));
#define logfile_sub_var_uint64(var,val) logfile_append (user_options, "%s\t%s\t%s\t%" PRIu64 "", data.topid, data.subid, (var), (val));
#define logfile_top_var_uint(var,val) logfile_append (user_options, "%s\t%s\t%u", data.topid, (var), (val));
#define logfile_sub_var_uint(var,val) logfile_append (user_options, "%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
#define logfile_top_var_char(var,val) logfile_append (user_options, "%s\t%s\t%c", data.topid, (var), (val));
#define logfile_sub_var_char(var,val) logfile_append (user_options, "%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (user_options, "%s\t%s\t%s", data.topid, (var), (val));
#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (user_options, "%s\t%s\t%s\t%s", data.topid, data.subid, (var), (val));
#define logfile_top_msg(msg) logfile_append (logfile_ctx, "%s\t%s", logfile_ctx->topid, (msg));
#define logfile_sub_msg(msg) logfile_append (logfile_ctx, "%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (msg));
#define logfile_top_var_uint64(var,val) logfile_append (logfile_ctx, "%s\t%s\t%" PRIu64 "", logfile_ctx->topid, (var), (val));
#define logfile_sub_var_uint64(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%" PRIu64 "", logfile_ctx->topid, logfile_ctx->subid, (var), (val));
#define logfile_top_var_uint(var,val) logfile_append (logfile_ctx, "%s\t%s\t%u", logfile_ctx->topid, (var), (val));
#define logfile_sub_var_uint(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%u", logfile_ctx->topid, logfile_ctx->subid, (var), (val));
#define logfile_top_var_char(var,val) logfile_append (logfile_ctx, "%s\t%s\t%c", logfile_ctx->topid, (var), (val));
#define logfile_sub_var_char(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%c", logfile_ctx->topid, logfile_ctx->subid, (var), (val));
#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (logfile_ctx, "%s\t%s\t%s", logfile_ctx->topid, (var), (val));
#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (logfile_ctx, "%s\t%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (var), (val));
#define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
#define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
#define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
#define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
#define logfile_top_char(var) logfile_top_var_char (#var, (var));
#define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
#define logfile_top_string(var) logfile_top_var_string (#var, (var));
#define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
char *logfile_generate_topid (void);
char *logfile_generate_subid (void);
void logfile_generate_topid (logfile_ctx_t *logfile_ctx);
void logfile_generate_subid (logfile_ctx_t *logfile_ctx);
void logfile_append (const user_options_t *user_options, const char *fmt, ...);
void logfile_append (const logfile_ctx_t *logfile_ctx, const char *fmt, ...);
void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config);
void logfile_destroy (logfile_ctx_t *logfile_ctx);
#endif // _LOGFILE_H
+11 -8
View File
@@ -186,6 +186,16 @@ typedef struct
} hash_t;
typedef struct
{
bool enabled;
char *logfile;
char *topid;
char *subid;
} logfile_ctx_t;
typedef struct
{
char *hashfile;
@@ -956,14 +966,6 @@ typedef struct
void *hm_xnvctrl;
hm_attrs_t hm_device[DEVICES_MAX];
/**
* logging
*/
char *logfile;
char *topid;
char *subid;
/**
* crack-per-time
*/
@@ -1000,6 +1002,7 @@ typedef struct
bitmap_ctx_t *bitmap_ctx;
induct_ctx_t *induct_ctx;
outcheck_ctx_t *outcheck_ctx;
logfile_ctx_t *logfile_ctx;
/**
* used for restore
+2
View File
@@ -253,4 +253,6 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
int user_options_extra_init (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra);
void user_options_logger (const user_options_t *user_options, const logfile_ctx_t *logfile_ctx);
#endif // _USER_OPTIONS_H