Coverage Report

Created: 2026-10-28 18:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5Clog_json.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*-------------------------------------------------------------------------
14
 *
15
 * Created:     H5Clog_json.c
16
 *
17
 * Purpose:     Cache log implementation that emits JSON-formatted log
18
 *              entries for consumption by new-fangled data analysis tools.
19
 *
20
 *-------------------------------------------------------------------------
21
 */
22
23
/****************/
24
/* Module Setup */
25
/****************/
26
#include "H5Cmodule.h" /* This source code file is part of the H5C module */
27
28
/***********/
29
/* Headers */
30
/***********/
31
#include "H5private.h"   /* Generic Functions                        */
32
#include "H5Cpkg.h"      /* Cache                                    */
33
#include "H5Clog.h"      /* Cache logging                            */
34
#include "H5Eprivate.h"  /* Error handling                           */
35
#include "H5MMprivate.h" /* Memory management                        */
36
37
/****************/
38
/* Local Macros */
39
/****************/
40
41
/* Max log message size */
42
0
#define H5C_MAX_JSON_LOG_MSG_SIZE 1024
43
44
/******************/
45
/* Local Typedefs */
46
/******************/
47
48
/********************/
49
/* Package Typedefs */
50
/********************/
51
52
typedef struct H5C_log_json_udata_t {
53
    FILE *outfile;
54
    char *message;
55
} H5C_log_json_udata_t;
56
57
/********************/
58
/* Local Prototypes */
59
/********************/
60
61
/* Internal message handling calls */
62
static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata);
63
64
/* Log message callbacks */
65
static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info);
66
static herr_t H5C__json_write_start_log_msg(void *udata);
67
static herr_t H5C__json_write_stop_log_msg(void *udata);
68
static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value);
69
static herr_t H5C__json_write_destroy_cache_log_msg(void *udata);
70
static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value);
71
static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id,
72
                                                    herr_t fxn_ret_value);
73
static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value);
74
static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags,
75
                                                   size_t size, herr_t fxn_ret_value);
76
static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry,
77
                                                       herr_t fxn_ret_value);
78
static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry,
79
                                                       herr_t fxn_ret_value);
80
static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
81
                                                              herr_t fxn_ret_value);
82
static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
83
                                                            herr_t fxn_ret_value);
84
static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id,
85
                                                 herr_t fxn_ret_value);
86
static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
87
                                                herr_t fxn_ret_value);
88
static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
89
                                                const H5C_cache_entry_t *child, herr_t fxn_ret_value);
90
static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id,
91
                                                    unsigned flags, herr_t fxn_ret_value);
92
static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
93
                                                   size_t new_size, herr_t fxn_ret_value);
94
static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
95
                                                  herr_t fxn_ret_value);
96
static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
97
                                                 const H5C_cache_entry_t *child, herr_t fxn_ret_value);
98
static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id,
99
                                                      unsigned flags, herr_t fxn_ret_value);
100
static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config,
101
                                                       herr_t fxn_ret_value);
102
static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
103
                                                   herr_t fxn_ret_value);
104
105
/*********************/
106
/* Package Variables */
107
/*********************/
108
109
/*****************************/
110
/* Library Private Variables */
111
/*****************************/
112
113
/*******************/
114
/* Local Variables */
115
/*******************/
116
117
/* Note that there's no cache set up call since that's the
118
 * place where this struct is wired into the cache.
119
 */
120
static const H5C_log_class_t H5C_json_log_class_g = {"json",
121
                                                     H5C__json_tear_down_logging,
122
                                                     NULL, /* start logging */
123
                                                     NULL, /* stop logging */
124
                                                     H5C__json_write_start_log_msg,
125
                                                     H5C__json_write_stop_log_msg,
126
                                                     H5C__json_write_create_cache_log_msg,
127
                                                     H5C__json_write_destroy_cache_log_msg,
128
                                                     H5C__json_write_evict_cache_log_msg,
129
                                                     H5C__json_write_expunge_entry_log_msg,
130
                                                     H5C__json_write_flush_cache_log_msg,
131
                                                     H5C__json_write_insert_entry_log_msg,
132
                                                     H5C__json_write_mark_entry_dirty_log_msg,
133
                                                     H5C__json_write_mark_entry_clean_log_msg,
134
                                                     H5C__json_write_mark_unserialized_entry_log_msg,
135
                                                     H5C__json_write_mark_serialized_entry_log_msg,
136
                                                     H5C__json_write_move_entry_log_msg,
137
                                                     H5C__json_write_pin_entry_log_msg,
138
                                                     H5C__json_write_create_fd_log_msg,
139
                                                     H5C__json_write_protect_entry_log_msg,
140
                                                     H5C__json_write_resize_entry_log_msg,
141
                                                     H5C__json_write_unpin_entry_log_msg,
142
                                                     H5C__json_write_destroy_fd_log_msg,
143
                                                     H5C__json_write_unprotect_entry_log_msg,
144
                                                     H5C__json_write_set_cache_config_log_msg,
145
                                                     H5C__json_write_remove_entry_log_msg};
146
147
/*-------------------------------------------------------------------------
148
 * Function:    H5C__json_write_log_message
149
 *
150
 * Purpose:     Write a message to the log file and flush the file.
151
 *              The message string is neither modified nor freed.
152
 *
153
 * Return:      SUCCEED/FAIL
154
 *
155
 *-------------------------------------------------------------------------
156
 */
157
static herr_t
158
H5C__json_write_log_message(H5C_log_json_udata_t *json_udata)
159
0
{
160
0
    size_t n_chars;
161
0
    herr_t ret_value = SUCCEED; /* Return value */
162
163
0
    FUNC_ENTER_PACKAGE
164
165
    /* Sanity checks */
166
0
    assert(json_udata);
167
0
    assert(json_udata->outfile);
168
0
    assert(json_udata->message);
169
170
    /* Write the log message and flush */
171
0
    n_chars = strlen(json_udata->message);
172
0
    if ((int)n_chars != fprintf(json_udata->outfile, "%s", json_udata->message))
173
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message");
174
0
    memset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char)));
175
176
0
done:
177
0
    FUNC_LEAVE_NOAPI(ret_value)
178
0
} /* H5C__json_write_log_message() */
179
180
/*-------------------------------------------------------------------------
181
 * Function:    H5C__log_json_set_up
182
 *
183
 * Purpose:     Setup for metadata cache logging.
184
 *
185
 *              Metadata logging is enabled and disabled at two levels. This
186
 *              function and the associated tear_down function open and close
187
 *              the log file. the start_ and stop_logging functions are then
188
 *              used to switch logging on/off. Optionally, logging can begin
189
 *              as soon as the log file is opened (set via the start_immediately
190
 *              parameter to this function).
191
 *
192
 *              The log functionality is split between the H5C and H5AC
193
 *              packages. Log state and direct log manipulation resides in
194
 *              H5C. Log messages are generated in H5AC and sent to
195
 *              the H5C__json_write_log_message function.
196
 *
197
 * Return:      SUCCEED/FAIL
198
 *
199
 *-------------------------------------------------------------------------
200
 */
201
herr_t
202
H5C__log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank)
203
0
{
204
0
    H5C_log_json_udata_t *json_udata = NULL;
205
0
    char                 *file_name  = NULL;
206
0
    size_t                n_chars;
207
0
    int                   log_file_fd = -1;
208
0
    herr_t                ret_value   = SUCCEED; /* Return value */
209
210
0
    FUNC_ENTER_PACKAGE
211
212
    /* Sanity checks */
213
0
    assert(log_info);
214
0
    assert(log_location);
215
216
    /* Set up the class struct */
217
0
    log_info->cls = &H5C_json_log_class_g;
218
219
    /* Allocate memory for the JSON-specific data */
220
0
    if (NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t))))
221
0
        HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed");
222
0
    json_udata = (H5C_log_json_udata_t *)(log_info->udata);
223
224
    /* Allocate memory for the message buffer */
225
0
    if (NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char))))
226
0
        HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed");
227
228
    /* Possibly fix up the log file name.
229
     * The extra 39 characters are for adding the rank to the file name
230
     * under parallel HDF5. 39 characters allows > 2^127 processes which
231
     * should be enough for anybody.
232
     *
233
     * allocation size = "RANK_" + <rank # length> + dot + <path length> + \0
234
     */
235
0
    n_chars = 5 + 39 + 1 + strlen(log_location) + 1;
236
0
    if (NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char))))
237
0
        HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL,
238
0
                    "can't allocate memory for mdc log file name manipulation");
239
240
    /* Add the rank to the log file name when MPI is in use */
241
0
    if (-1 == mpi_rank)
242
0
        snprintf(file_name, n_chars, "%s", log_location);
243
0
    else
244
0
        snprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location);
245
246
    /* Open log file and set it to be unbuffered */
247
0
    if ((log_file_fd = HDopen(file_name, O_WRONLY | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_URWGROR)) < 0)
248
0
        HSYS_GOTO_ERROR(H5E_CACHE, H5E_CANTOPENFILE, FAIL, "can't create mdc log file");
249
0
    if (NULL == (json_udata->outfile = HDfdopen(log_file_fd, "w"))) {
250
0
        HDclose(log_file_fd);
251
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file");
252
0
    }
253
0
    setbuf(json_udata->outfile, NULL);
254
255
0
done:
256
0
    if (file_name)
257
0
        H5MM_xfree(file_name);
258
259
    /* Free and reset the log info struct on errors */
260
0
    if (FAIL == ret_value) {
261
        /* Free */
262
0
        if (json_udata && json_udata->message)
263
0
            H5MM_xfree(json_udata->message);
264
0
        if (json_udata)
265
0
            H5MM_xfree(json_udata);
266
267
        /* Reset */
268
0
        log_info->udata = NULL;
269
0
        log_info->cls   = NULL;
270
0
    }
271
272
0
    FUNC_LEAVE_NOAPI(ret_value)
273
0
} /* H5C__log_json_set_up() */
274
275
/*-------------------------------------------------------------------------
276
 * Function:    H5C__json_tear_down_logging
277
 *
278
 * Purpose:     Tear-down for metadata cache logging.
279
 *
280
 * Return:      SUCCEED/FAIL
281
 *
282
 *-------------------------------------------------------------------------
283
 */
284
static herr_t
285
H5C__json_tear_down_logging(H5C_log_info_t *log_info)
286
0
{
287
0
    H5C_log_json_udata_t *json_udata = NULL;
288
0
    herr_t                ret_value  = SUCCEED; /* Return value */
289
290
0
    FUNC_ENTER_PACKAGE
291
292
    /* Sanity checks */
293
0
    assert(log_info);
294
295
    /* Alias */
296
0
    json_udata = (H5C_log_json_udata_t *)(log_info->udata);
297
298
    /* Free the message buffer */
299
0
    H5MM_xfree(json_udata->message);
300
301
    /* Close log file */
302
0
    if (EOF == fclose(json_udata->outfile))
303
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file");
304
0
    json_udata->outfile = NULL;
305
306
    /* Fre the udata */
307
0
    H5MM_xfree(json_udata);
308
309
    /* Reset the log class info and udata */
310
0
    log_info->cls   = NULL;
311
0
    log_info->udata = NULL;
312
313
0
done:
314
0
    FUNC_LEAVE_NOAPI(ret_value)
315
0
} /* H5C__json_tear_down_logging() */
316
317
/*-------------------------------------------------------------------------
318
 * Function:    H5C__json_write_start_log_msg
319
 *
320
 * Purpose:     Write a log message when logging starts.
321
 *
322
 * Return:      SUCCEED/FAIL
323
 *
324
 *-------------------------------------------------------------------------
325
 */
326
static herr_t
327
H5C__json_write_start_log_msg(void *udata)
328
0
{
329
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
330
0
    herr_t                ret_value  = SUCCEED; /* Return value */
331
332
0
    FUNC_ENTER_PACKAGE
333
334
    /* Sanity checks */
335
0
    assert(json_udata);
336
0
    assert(json_udata->message);
337
338
    /* Create the log message string (opens the JSON array) */
339
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
340
0
{\n\
341
0
\"HDF5 metadata cache log messages\" : [\n\
342
0
{\
343
0
\"timestamp\":%lld,\
344
0
\"action\":\"logging start\"\
345
0
},\n\
346
0
",
347
0
             (long long)time(NULL));
348
349
    /* Write the log message to the file */
350
0
    if (H5C__json_write_log_message(json_udata) < 0)
351
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
352
353
0
done:
354
0
    FUNC_LEAVE_NOAPI(ret_value)
355
0
} /* H5C__json_write_start_log_msg() */
356
357
/*-------------------------------------------------------------------------
358
 * Function:    H5C__json_write_stop_log_msg
359
 *
360
 * Purpose:     Write a log message when logging ends.
361
 *
362
 * Return:      SUCCEED/FAIL
363
 *
364
 *-------------------------------------------------------------------------
365
 */
366
static herr_t
367
H5C__json_write_stop_log_msg(void *udata)
368
0
{
369
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
370
0
    herr_t                ret_value  = SUCCEED; /* Return value */
371
372
0
    FUNC_ENTER_PACKAGE
373
374
    /* Sanity checks */
375
0
    assert(json_udata);
376
0
    assert(json_udata->message);
377
378
    /* Create the log message string (closes the JSON array) */
379
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
380
0
{\
381
0
\"timestamp\":%lld,\
382
0
\"action\":\"logging stop\"\
383
0
}\n\
384
0
]}\n\
385
0
",
386
0
             (long long)time(NULL));
387
388
    /* Write the log message to the file */
389
0
    if (H5C__json_write_log_message(json_udata) < 0)
390
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
391
392
0
done:
393
0
    FUNC_LEAVE_NOAPI(ret_value)
394
0
} /* H5C__json_write_stop_log_msg() */
395
396
/*-------------------------------------------------------------------------
397
 * Function:    H5C__json_write_create_cache_log_msg
398
 *
399
 * Purpose:     Write a log message for cache creation.
400
 *
401
 * Return:      SUCCEED/FAIL
402
 *
403
 *-------------------------------------------------------------------------
404
 */
405
static herr_t
406
H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value)
407
0
{
408
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
409
0
    herr_t                ret_value  = SUCCEED; /* Return value */
410
411
0
    FUNC_ENTER_PACKAGE
412
413
    /* Sanity checks */
414
0
    assert(json_udata);
415
0
    assert(json_udata->message);
416
417
    /* Create the log message string */
418
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
419
0
{\
420
0
\"timestamp\":%lld,\
421
0
\"action\":\"create\",\
422
0
\"returned\":%d\
423
0
},\n\
424
0
",
425
0
             (long long)time(NULL), (int)fxn_ret_value);
426
427
    /* Write the log message to the file */
428
0
    if (H5C__json_write_log_message(json_udata) < 0)
429
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
430
431
0
done:
432
0
    FUNC_LEAVE_NOAPI(ret_value)
433
0
} /* H5C__json_write_create_cache_log_msg() */
434
435
/*-------------------------------------------------------------------------
436
 * Function:    H5C__json_write_destroy_cache_log_msg
437
 *
438
 * Purpose:     Write a log message for cache destruction.
439
 *
440
 * Return:      SUCCEED/FAIL
441
 *
442
 *-------------------------------------------------------------------------
443
 */
444
static herr_t
445
H5C__json_write_destroy_cache_log_msg(void *udata)
446
0
{
447
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
448
0
    herr_t                ret_value  = SUCCEED; /* Return value */
449
450
0
    FUNC_ENTER_PACKAGE
451
452
    /* Sanity checks */
453
0
    assert(json_udata);
454
0
    assert(json_udata->message);
455
456
    /* Create the log message string */
457
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
458
0
{\
459
0
\"timestamp\":%lld,\
460
0
\"action\":\"destroy\"\
461
0
},\n\
462
0
",
463
0
             (long long)time(NULL));
464
465
    /* Write the log message to the file */
466
0
    if (H5C__json_write_log_message(json_udata) < 0)
467
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
468
469
0
done:
470
0
    FUNC_LEAVE_NOAPI(ret_value)
471
0
} /* H5C__json_write_destroy_cache_log_msg() */
472
473
/*-------------------------------------------------------------------------
474
 * Function:    H5C__json_write_evict_cache_log_msg
475
 *
476
 * Purpose:     Write a log message for eviction of cache entries.
477
 *
478
 * Return:      SUCCEED/FAIL
479
 *
480
 *-------------------------------------------------------------------------
481
 */
482
static herr_t
483
H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value)
484
0
{
485
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
486
0
    herr_t                ret_value  = SUCCEED;
487
488
0
    FUNC_ENTER_PACKAGE
489
490
    /* Sanity checks */
491
0
    assert(json_udata);
492
0
    assert(json_udata->message);
493
494
    /* Create the log message string */
495
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
496
0
{\
497
0
\"timestamp\":%lld,\
498
0
\"action\":\"evict\",\
499
0
\"returned\":%d\
500
0
},\n\
501
0
",
502
0
             (long long)time(NULL), (int)fxn_ret_value);
503
504
    /* Write the log message to the file */
505
0
    if (H5C__json_write_log_message(json_udata) < 0)
506
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
507
508
0
done:
509
0
    FUNC_LEAVE_NOAPI(ret_value)
510
0
} /* H5C__json_write_evict_cache_log_msg() */
511
512
/*-------------------------------------------------------------------------
513
 * Function:    H5C__json_write_expunge_entry_log_msg
514
 *
515
 * Purpose:     Write a log message for expunge of cache entries.
516
 *
517
 * Return:      SUCCEED/FAIL
518
 *
519
 *-------------------------------------------------------------------------
520
 */
521
static herr_t
522
H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value)
523
0
{
524
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
525
0
    herr_t                ret_value  = SUCCEED;
526
527
0
    FUNC_ENTER_PACKAGE
528
529
    /* Sanity checks */
530
0
    assert(json_udata);
531
0
    assert(json_udata->message);
532
533
    /* Create the log message string */
534
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
535
0
{\
536
0
\"timestamp\":%lld,\
537
0
\"action\":\"expunge\",\
538
0
\"address\":0x%lx,\
539
0
\"type_id\":%d,\
540
0
\"returned\":%d\
541
0
},\n\
542
0
",
543
0
             (long long)time(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value);
544
545
    /* Write the log message to the file */
546
0
    if (H5C__json_write_log_message(json_udata) < 0)
547
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
548
549
0
done:
550
0
    FUNC_LEAVE_NOAPI(ret_value)
551
0
} /* H5C__json_write_expunge_entry_log_msg() */
552
553
/*-------------------------------------------------------------------------
554
 * Function:    H5C__json_write_flush_cache_log_msg
555
 *
556
 * Purpose:     Write a log message for cache flushes.
557
 *
558
 * Return:      SUCCEED/FAIL
559
 *
560
 *-------------------------------------------------------------------------
561
 */
562
static herr_t
563
H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value)
564
0
{
565
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
566
0
    herr_t                ret_value  = SUCCEED;
567
568
0
    FUNC_ENTER_PACKAGE
569
570
    /* Sanity checks */
571
0
    assert(json_udata);
572
0
    assert(json_udata->message);
573
574
    /* Create the log message string */
575
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
576
0
{\
577
0
\"timestamp\":%lld,\
578
0
\"action\":\"flush\",\
579
0
\"returned\":%d\
580
0
},\n\
581
0
",
582
0
             (long long)time(NULL), (int)fxn_ret_value);
583
584
    /* Write the log message to the file */
585
0
    if (H5C__json_write_log_message(json_udata) < 0)
586
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
587
588
0
done:
589
0
    FUNC_LEAVE_NOAPI(ret_value)
590
0
} /* H5C__json_write_flush_cache_log_msg() */
591
592
/*-------------------------------------------------------------------------
593
 * Function:    H5C__json_write_insert_entry_log_msg
594
 *
595
 * Purpose:     Write a log message for insertion of cache entries.
596
 *
597
 * Return:      SUCCEED/FAIL
598
 *
599
 *-------------------------------------------------------------------------
600
 */
601
static herr_t
602
H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size,
603
                                     herr_t fxn_ret_value)
604
0
{
605
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
606
0
    herr_t                ret_value  = SUCCEED;
607
608
0
    FUNC_ENTER_PACKAGE
609
610
    /* Sanity checks */
611
0
    assert(json_udata);
612
0
    assert(json_udata->message);
613
614
    /* Create the log message string */
615
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
616
0
{\
617
0
\"timestamp\":%lld,\
618
0
\"action\":\"insert\",\
619
0
\"address\":0x%lx,\
620
0
\"type_id\":%d,\
621
0
\"flags\":0x%x,\
622
0
\"size\":%d,\
623
0
\"returned\":%d\
624
0
},\n\
625
0
",
626
0
             (long long)time(NULL), (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value);
627
628
    /* Write the log message to the file */
629
0
    if (H5C__json_write_log_message(json_udata) < 0)
630
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
631
632
0
done:
633
0
    FUNC_LEAVE_NOAPI(ret_value)
634
0
} /* H5C__json_write_insert_entry_log_msg() */
635
636
/*-------------------------------------------------------------------------
637
 * Function:    H5C__json_write_mark_entry_dirty_log_msg
638
 *
639
 * Purpose:     Write a log message for marking cache entries as dirty.
640
 *
641
 * Return:      SUCCEED/FAIL
642
 *
643
 *-------------------------------------------------------------------------
644
 */
645
static herr_t
646
H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
647
0
{
648
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
649
0
    herr_t                ret_value  = SUCCEED;
650
651
0
    FUNC_ENTER_PACKAGE
652
653
    /* Sanity checks */
654
0
    assert(json_udata);
655
0
    assert(json_udata->message);
656
0
    assert(entry);
657
658
    /* Create the log message string */
659
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
660
0
{\
661
0
\"timestamp\":%lld,\
662
0
\"action\":\"dirty\",\
663
0
\"address\":0x%lx,\
664
0
\"returned\":%d\
665
0
},\n\
666
0
",
667
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
668
669
    /* Write the log message to the file */
670
0
    if (H5C__json_write_log_message(json_udata) < 0)
671
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
672
673
0
done:
674
0
    FUNC_LEAVE_NOAPI(ret_value)
675
0
} /* H5C__json_write_mark_entry_dirty_log_msg() */
676
677
/*-------------------------------------------------------------------------
678
 * Function:    H5C__json_write_mark_entry_clean_log_msg
679
 *
680
 * Purpose:     Write a log message for marking cache entries as clean.
681
 *
682
 * Return:      SUCCEED/FAIL
683
 *
684
 *-------------------------------------------------------------------------
685
 */
686
static herr_t
687
H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
688
0
{
689
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
690
0
    herr_t                ret_value  = SUCCEED; /* Return value */
691
692
0
    FUNC_ENTER_PACKAGE
693
694
    /* Sanity checks */
695
0
    assert(json_udata);
696
0
    assert(json_udata->message);
697
0
    assert(entry);
698
699
    /* Create the log message string */
700
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
701
0
{\
702
0
\"timestamp\":%lld,\
703
0
\"action\":\"clean\",\
704
0
\"address\":0x%lx,\
705
0
\"returned\":%d\
706
0
},\n\
707
0
",
708
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
709
710
    /* Write the log message to the file */
711
0
    if (H5C__json_write_log_message(json_udata) < 0)
712
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
713
714
0
done:
715
0
    FUNC_LEAVE_NOAPI(ret_value)
716
0
} /* H5C__json_write_mark_entry_clean_log_msg() */
717
718
/*-------------------------------------------------------------------------
719
 * Function:    H5C__json_write_mark_unserialized_entry_log_msg
720
 *
721
 * Purpose:     Write a log message for marking cache entries as unserialized.
722
 *
723
 * Return:      SUCCEED/FAIL
724
 *
725
 *-------------------------------------------------------------------------
726
 */
727
static herr_t
728
H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
729
                                                herr_t fxn_ret_value)
730
0
{
731
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
732
0
    herr_t                ret_value  = SUCCEED;
733
734
0
    FUNC_ENTER_PACKAGE
735
736
    /* Sanity checks */
737
0
    assert(json_udata);
738
0
    assert(json_udata->message);
739
0
    assert(entry);
740
741
    /* Create the log message string */
742
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
743
0
{\
744
0
\"timestamp\":%lld,\
745
0
\"action\":\"unserialized\",\
746
0
\"address\":0x%lx,\
747
0
\"returned\":%d\
748
0
},\n\
749
0
",
750
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
751
752
    /* Write the log message to the file */
753
0
    if (H5C__json_write_log_message(json_udata) < 0)
754
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
755
756
0
done:
757
0
    FUNC_LEAVE_NOAPI(ret_value)
758
0
} /* H5C__json_write_mark_unserialized_entry_log_msg() */
759
760
/*-------------------------------------------------------------------------
761
 * Function:    H5C__json_write_mark_serialize_entry_log_msg
762
 *
763
 * Purpose:     Write a log message for marking cache entries as serialize.
764
 *
765
 * Return:      SUCCEED/FAIL
766
 *
767
 *-------------------------------------------------------------------------
768
 */
769
static herr_t
770
H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry,
771
                                              herr_t fxn_ret_value)
772
0
{
773
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
774
0
    herr_t                ret_value  = SUCCEED; /* Return value */
775
776
0
    FUNC_ENTER_PACKAGE
777
778
    /* Sanity checks */
779
0
    assert(json_udata);
780
0
    assert(json_udata->message);
781
0
    assert(entry);
782
783
    /* Create the log message string */
784
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
785
0
{\
786
0
\"timestamp\":%lld,\
787
0
\"action\":\"serialized\",\
788
0
\"address\":0x%lx,\
789
0
\"returned\":%d\
790
0
},\n\
791
0
",
792
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
793
794
    /* Write the log message to the file */
795
0
    if (H5C__json_write_log_message(json_udata) < 0)
796
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
797
798
0
done:
799
0
    FUNC_LEAVE_NOAPI(ret_value)
800
0
} /* H5C__json_write_mark_serialized_entry_log_msg() */
801
802
/*-------------------------------------------------------------------------
803
 * Function:    H5C__json_write_move_entry_log_msg
804
 *
805
 * Purpose:     Write a log message for moving a cache entry.
806
 *
807
 * Return:      SUCCEED/FAIL
808
 *
809
 *-------------------------------------------------------------------------
810
 */
811
static herr_t
812
H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id,
813
                                   herr_t fxn_ret_value)
814
0
{
815
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
816
0
    herr_t                ret_value  = SUCCEED;
817
818
0
    FUNC_ENTER_PACKAGE
819
820
    /* Sanity checks */
821
0
    assert(json_udata);
822
0
    assert(json_udata->message);
823
824
    /* Create the log message string */
825
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
826
0
{\
827
0
\"timestamp\":%lld,\
828
0
\"action\":\"move\",\
829
0
\"old_address\":0x%lx,\
830
0
\"new_address\":0x%lx,\
831
0
\"type_id\":%d,\
832
0
\"returned\":%d\
833
0
},\n\
834
0
",
835
0
             (long long)time(NULL), (unsigned long)old_addr, (unsigned long)new_addr, type_id,
836
0
             (int)fxn_ret_value);
837
838
    /* Write the log message to the file */
839
0
    if (H5C__json_write_log_message(json_udata) < 0)
840
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
841
842
0
done:
843
0
    FUNC_LEAVE_NOAPI(ret_value)
844
0
} /* H5C__json_write_move_entry_log_msg() */
845
846
/*-------------------------------------------------------------------------
847
 * Function:    H5C__json_write_pin_entry_log_msg
848
 *
849
 * Purpose:     Write a log message for pinning a cache entry.
850
 *
851
 * Return:      SUCCEED/FAIL
852
 *
853
 *-------------------------------------------------------------------------
854
 */
855
static herr_t
856
H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
857
0
{
858
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
859
0
    herr_t                ret_value  = SUCCEED;
860
861
0
    FUNC_ENTER_PACKAGE
862
863
    /* Sanity checks */
864
0
    assert(json_udata);
865
0
    assert(json_udata->message);
866
0
    assert(entry);
867
868
    /* Create the log message string */
869
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
870
0
{\
871
0
\"timestamp\":%lld,\
872
0
\"action\":\"pin\",\
873
0
\"address\":0x%lx,\
874
0
\"returned\":%d\
875
0
},\n\
876
0
",
877
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
878
879
    /* Write the log message to the file */
880
0
    if (H5C__json_write_log_message(json_udata) < 0)
881
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
882
883
0
done:
884
0
    FUNC_LEAVE_NOAPI(ret_value)
885
0
} /* H5C__json_write_pin_entry_log_msg() */
886
887
/*-------------------------------------------------------------------------
888
 * Function:    H5C__json_write_create_fd_log_msg
889
 *
890
 * Purpose:     Write a log message for creating a flush dependency between
891
 *              two cache entries.
892
 *
893
 * Return:      SUCCEED/FAIL
894
 *
895
 *-------------------------------------------------------------------------
896
 */
897
static herr_t
898
H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
899
                                  const H5C_cache_entry_t *child, herr_t fxn_ret_value)
900
0
{
901
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
902
0
    herr_t                ret_value  = SUCCEED;
903
904
0
    FUNC_ENTER_PACKAGE
905
906
    /* Sanity checks */
907
0
    assert(json_udata);
908
0
    assert(json_udata->message);
909
0
    assert(parent);
910
0
    assert(child);
911
912
    /* Create the log message string */
913
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
914
0
{\
915
0
\"timestamp\":%lld,\
916
0
\"action\":\"create_fd\",\
917
0
\"parent_addr\":0x%lx,\
918
0
\"child_addr\":0x%lx,\
919
0
\"returned\":%d\
920
0
},\n\
921
0
",
922
0
             (long long)time(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
923
0
             (int)fxn_ret_value);
924
925
    /* Write the log message to the file */
926
0
    if (H5C__json_write_log_message(json_udata) < 0)
927
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
928
929
0
done:
930
0
    FUNC_LEAVE_NOAPI(ret_value)
931
0
} /* H5C__json_write_create_fd_log_msg() */
932
933
/*-------------------------------------------------------------------------
934
 * Function:    H5C__json_write_protect_entry_log_msg
935
 *
936
 * Purpose:     Write a log message for protecting a cache entry.
937
 *
938
 * Return:      SUCCEED/FAIL
939
 *
940
 *-------------------------------------------------------------------------
941
 */
942
static herr_t
943
H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id,
944
                                      unsigned flags, herr_t fxn_ret_value)
945
0
{
946
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
947
0
    char                  rw_s[16];
948
0
    herr_t                ret_value = SUCCEED;
949
950
0
    FUNC_ENTER_PACKAGE
951
952
    /* Sanity checks */
953
0
    assert(json_udata);
954
0
    assert(json_udata->message);
955
0
    assert(entry);
956
957
0
    if (H5C__READ_ONLY_FLAG == flags)
958
0
        strcpy(rw_s, "READ");
959
0
    else
960
0
        strcpy(rw_s, "WRITE");
961
962
    /* Create the log message string */
963
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
964
0
{\
965
0
\"timestamp\":%lld,\
966
0
\"action\":\"protect\",\
967
0
\"address\":0x%lx,\
968
0
\"type_id\":%d,\
969
0
\"readwrite\":\"%s\",\
970
0
\"size\":%d,\
971
0
\"returned\":%d\
972
0
},\n\
973
0
",
974
0
             (long long)time(NULL), (unsigned long)entry->addr, type_id, rw_s, (int)entry->size,
975
0
             (int)fxn_ret_value);
976
977
    /* Write the log message to the file */
978
0
    if (H5C__json_write_log_message(json_udata) < 0)
979
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
980
981
0
done:
982
0
    FUNC_LEAVE_NOAPI(ret_value)
983
0
} /* H5C__json_write_protect_entry_log_msg() */
984
985
/*-------------------------------------------------------------------------
986
 * Function:    H5C__json_write_resize_entry_log_msg
987
 *
988
 * Purpose:     Write a log message for resizing a cache entry.
989
 *
990
 * Return:      SUCCEED/FAIL
991
 *
992
 *-------------------------------------------------------------------------
993
 */
994
static herr_t
995
H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size,
996
                                     herr_t fxn_ret_value)
997
0
{
998
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
999
0
    herr_t                ret_value  = SUCCEED;
1000
1001
0
    FUNC_ENTER_PACKAGE
1002
1003
    /* Sanity checks */
1004
0
    assert(json_udata);
1005
0
    assert(json_udata->message);
1006
0
    assert(entry);
1007
1008
    /* Create the log message string */
1009
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1010
0
{\
1011
0
\"timestamp\":%lld,\
1012
0
\"action\":\"resize\",\
1013
0
\"address\":0x%lx,\
1014
0
\"new_size\":%d,\
1015
0
\"returned\":%d\
1016
0
},\n\
1017
0
",
1018
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)new_size, (int)fxn_ret_value);
1019
1020
    /* Write the log message to the file */
1021
0
    if (H5C__json_write_log_message(json_udata) < 0)
1022
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1023
1024
0
done:
1025
0
    FUNC_LEAVE_NOAPI(ret_value)
1026
0
} /* H5C__json_write_resize_entry_log_msg() */
1027
1028
/*-------------------------------------------------------------------------
1029
 * Function:    H5C__json_write_unpin_entry_log_msg
1030
 *
1031
 * Purpose:     Write a log message for unpinning a cache entry.
1032
 *
1033
 * Return:      SUCCEED/FAIL
1034
 *
1035
 *-------------------------------------------------------------------------
1036
 */
1037
static herr_t
1038
H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
1039
0
{
1040
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1041
0
    herr_t                ret_value  = SUCCEED;
1042
1043
0
    FUNC_ENTER_PACKAGE
1044
1045
    /* Sanity checks */
1046
0
    assert(json_udata);
1047
0
    assert(json_udata->message);
1048
0
    assert(entry);
1049
1050
    /* Create the log message string */
1051
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1052
0
{\
1053
0
\"timestamp\":%lld,\
1054
0
\"action\":\"unpin\",\
1055
0
\"address\":0x%lx,\
1056
0
\"returned\":%d\
1057
0
},\n\
1058
0
",
1059
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
1060
1061
    /* Write the log message to the file */
1062
0
    if (H5C__json_write_log_message(json_udata) < 0)
1063
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1064
1065
0
done:
1066
0
    FUNC_LEAVE_NOAPI(ret_value)
1067
0
} /* H5C__json_write_unpin_entry_log_msg() */
1068
1069
/*-------------------------------------------------------------------------
1070
 * Function:    H5C__json_write_destroy_fd_log_msg
1071
 *
1072
 * Purpose:     Write a log message for destroying a flush dependency
1073
 *              between two cache entries.
1074
 *
1075
 * Return:      SUCCEED/FAIL
1076
 *
1077
 *-------------------------------------------------------------------------
1078
 */
1079
static herr_t
1080
H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent,
1081
                                   const H5C_cache_entry_t *child, herr_t fxn_ret_value)
1082
0
{
1083
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1084
0
    herr_t                ret_value  = SUCCEED;
1085
1086
0
    FUNC_ENTER_PACKAGE
1087
1088
    /* Sanity checks */
1089
0
    assert(json_udata);
1090
0
    assert(json_udata->message);
1091
0
    assert(parent);
1092
0
    assert(child);
1093
1094
    /* Create the log message string */
1095
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1096
0
{\
1097
0
\"timestamp\":%lld,\
1098
0
\"action\":\"destroy_fd\",\
1099
0
\"parent_addr\":0x%lx,\
1100
0
\"child_addr\":0x%lx,\
1101
0
\"returned\":%d\
1102
0
},\n\
1103
0
",
1104
0
             (long long)time(NULL), (unsigned long)parent->addr, (unsigned long)child->addr,
1105
0
             (int)fxn_ret_value);
1106
1107
    /* Write the log message to the file */
1108
0
    if (H5C__json_write_log_message(json_udata) < 0)
1109
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1110
1111
0
done:
1112
0
    FUNC_LEAVE_NOAPI(ret_value)
1113
0
} /* H5C__json_write_destroy_fd_log_msg() */
1114
1115
/*-------------------------------------------------------------------------
1116
 * Function:    H5C__json_write_unprotect_entry_log_msg
1117
 *
1118
 * Purpose:     Write a log message for unprotecting a cache entry.
1119
 *
1120
 * Return:      SUCCEED/FAIL
1121
 *
1122
 *-------------------------------------------------------------------------
1123
 */
1124
static herr_t
1125
H5C__json_write_unprotect_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags,
1126
                                        herr_t fxn_ret_value)
1127
0
{
1128
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1129
0
    herr_t                ret_value  = SUCCEED;
1130
1131
0
    FUNC_ENTER_PACKAGE
1132
1133
    /* Sanity checks */
1134
0
    assert(json_udata);
1135
0
    assert(json_udata->message);
1136
1137
    /* Create the log message string */
1138
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1139
0
{\
1140
0
\"timestamp\":%lld,\
1141
0
\"action\":\"unprotect\",\
1142
0
\"address\":0x%lx,\
1143
0
\"id\":%d,\
1144
0
\"flags\":%x,\
1145
0
\"returned\":%d\
1146
0
},\n\
1147
0
",
1148
0
             (long long)time(NULL), (unsigned long)address, type_id, flags, (int)fxn_ret_value);
1149
1150
    /* Write the log message to the file */
1151
0
    if (H5C__json_write_log_message(json_udata) < 0)
1152
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1153
1154
0
done:
1155
0
    FUNC_LEAVE_NOAPI(ret_value)
1156
0
} /* H5C__json_write_unprotect_entry_log_msg() */
1157
1158
/*-------------------------------------------------------------------------
1159
 * Function:    H5C__json_write_set_cache_config_log_msg
1160
 *
1161
 * Purpose:     Write a log message for setting the cache configuration.
1162
 *
1163
 * Return:      SUCCEED/FAIL
1164
 *
1165
 *-------------------------------------------------------------------------
1166
 */
1167
static herr_t
1168
H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t H5_ATTR_NDEBUG_UNUSED *config,
1169
                                         herr_t fxn_ret_value)
1170
0
{
1171
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1172
0
    herr_t                ret_value  = SUCCEED;
1173
1174
0
    FUNC_ENTER_PACKAGE
1175
1176
    /* Sanity checks */
1177
0
    assert(json_udata);
1178
0
    assert(json_udata->message);
1179
0
    assert(config);
1180
1181
    /* Create the log message string */
1182
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1183
0
{\
1184
0
\"timestamp\":%lld,\
1185
0
\"action\":\"set_config\",\
1186
0
\"returned\":%d\
1187
0
},\n\
1188
0
",
1189
0
             (long long)time(NULL), (int)fxn_ret_value);
1190
1191
    /* Write the log message to the file */
1192
0
    if (H5C__json_write_log_message(json_udata) < 0)
1193
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1194
1195
0
done:
1196
0
    FUNC_LEAVE_NOAPI(ret_value)
1197
0
} /* H5C__json_write_set_cache_config_log_msg() */
1198
1199
/*-------------------------------------------------------------------------
1200
 * Function:    H5C__json_write_remove_entry_log_msg
1201
 *
1202
 * Purpose:     Write a log message for removing a cache entry.
1203
 *
1204
 * Return:      SUCCEED/FAIL
1205
 *
1206
 *-------------------------------------------------------------------------
1207
 */
1208
static herr_t
1209
H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
1210
0
{
1211
0
    H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata);
1212
0
    herr_t                ret_value  = SUCCEED;
1213
1214
0
    FUNC_ENTER_PACKAGE
1215
1216
    /* Sanity checks */
1217
0
    assert(json_udata);
1218
0
    assert(json_udata->message);
1219
0
    assert(entry);
1220
1221
    /* Create the log message string */
1222
0
    snprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, "\
1223
0
{\
1224
0
\"timestamp\":%lld,\
1225
0
\"action\":\"remove\",\
1226
0
\"address\":0x%lx,\
1227
0
\"returned\":%d\
1228
0
},\n\
1229
0
",
1230
0
             (long long)time(NULL), (unsigned long)entry->addr, (int)fxn_ret_value);
1231
1232
    /* Write the log message to the file */
1233
0
    if (H5C__json_write_log_message(json_udata) < 0)
1234
0
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message");
1235
1236
0
done:
1237
0
    FUNC_LEAVE_NOAPI(ret_value)
1238
0
} /* H5C__json_write_remove_entry_log_msg() */