xref: /petsc/src/sys/logging/handler/interface/loghandler.c (revision 8b08f49465a30f8da2431a02b9bf7861043ec889)
119ef957cSToby Isaac 
219ef957cSToby Isaac #include <petscviewer.h>
319ef957cSToby Isaac #include <petsc/private/logimpl.h> /*I "petscsys.h" I*/
419ef957cSToby Isaac #include <petsc/private/loghandlerimpl.h>
5dff009beSToby Isaac #include <petsc/private/petscimpl.h>
619ef957cSToby Isaac 
719ef957cSToby Isaac /*@
819ef957cSToby Isaac   PetscLogHandlerCreate - Create a log handler for profiling events and stages.  PETSc
919ef957cSToby Isaac   provides several implementations of `PetscLogHandler` that interface to different ways to
1019ef957cSToby Isaac   summarize or visualize profiling data: see `PetscLogHandlerType` for a list.
1119ef957cSToby Isaac 
1219ef957cSToby Isaac   Collective
1319ef957cSToby Isaac 
1419ef957cSToby Isaac   Input Parameter:
1519ef957cSToby Isaac . comm - the communicator for synchronizing and viewing events with this handler
1619ef957cSToby Isaac 
1719ef957cSToby Isaac   Output Parameter:
1819ef957cSToby Isaac . handler - the `PetscLogHandler`
1919ef957cSToby Isaac 
2019ef957cSToby Isaac   Level: developer
2119ef957cSToby Isaac 
2219ef957cSToby Isaac   Notes:
2319ef957cSToby Isaac   This does not put the handler in use in PETSc's global logging system: use `PetscLogHandlerStart()` after creation.
2419ef957cSToby Isaac 
2519ef957cSToby Isaac   See `PetscLogHandler` for example usage.
2619ef957cSToby Isaac 
2719ef957cSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogHandlerSetType()`, `PetscLogHandlerStart()`, `PetscLogHandlerStop()`
2819ef957cSToby Isaac @*/
2919ef957cSToby Isaac PetscErrorCode PetscLogHandlerCreate(MPI_Comm comm, PetscLogHandler *handler)
3019ef957cSToby Isaac {
3119ef957cSToby Isaac   PetscLogHandler h;
3219ef957cSToby Isaac 
3319ef957cSToby Isaac   PetscFunctionBegin;
3419ef957cSToby Isaac   *handler = NULL;
3519ef957cSToby Isaac   PetscCall(PetscLogHandlerPackageInitialize());
3619ef957cSToby Isaac   // We do not use PetscHeaderCreate() here because having PetscLogObjectCreate() run for PetscLogHandler would be very fragile
3719ef957cSToby Isaac   PetscCall(PetscNew(&h));
3819ef957cSToby Isaac   PetscCall(PetscHeaderCreate_Private((PetscObject)(h), PETSCLOGHANDLER_CLASSID, "PetscLogHandler", "Profile events, stages, and objects", "Profiling", comm, (PetscObjectDestroyFunction)PetscLogHandlerDestroy, (PetscObjectViewFunction)PetscLogHandlerView));
3919ef957cSToby Isaac   *handler = h;
4019ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
4119ef957cSToby Isaac }
4219ef957cSToby Isaac 
4319ef957cSToby Isaac /*@
4419ef957cSToby Isaac   PetscLogHandlerDestroy - Destroy a `PetscLogHandler`
4519ef957cSToby Isaac 
4619ef957cSToby Isaac   Logically collective
4719ef957cSToby Isaac 
4819ef957cSToby Isaac   Input Parameter:
4919ef957cSToby Isaac . handler - handler to be destroyed
5019ef957cSToby Isaac 
5119ef957cSToby Isaac   Level: developer
5219ef957cSToby Isaac 
5319ef957cSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogHandlerCreate()`
5419ef957cSToby Isaac @*/
5519ef957cSToby Isaac PetscErrorCode PetscLogHandlerDestroy(PetscLogHandler *handler)
5619ef957cSToby Isaac {
5719ef957cSToby Isaac   PetscLogHandler h;
5819ef957cSToby Isaac 
5919ef957cSToby Isaac   PetscFunctionBegin;
6019ef957cSToby Isaac   if (!*handler) PetscFunctionReturn(PETSC_SUCCESS);
6119ef957cSToby Isaac   h        = *handler;
6219ef957cSToby Isaac   *handler = NULL;
6319ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
6419ef957cSToby Isaac   if (--((PetscObject)h)->refct > 0) PetscFunctionReturn(PETSC_SUCCESS);
6519ef957cSToby Isaac   PetscTryTypeMethod(h, destroy);
6619ef957cSToby Isaac   PetscCall(PetscLogStateDestroy(&h->state));
6719ef957cSToby Isaac   // We do not use PetscHeaderDestroy() because having PetscLogObjectDestroy() run for PetscLgoHandler would be very fragile
6819ef957cSToby Isaac   PetscCall(PetscHeaderDestroy_Private((PetscObject)(h), PETSC_FALSE));
6919ef957cSToby Isaac   PetscCall(PetscFree(h));
7019ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
7119ef957cSToby Isaac }
7219ef957cSToby Isaac 
7319ef957cSToby Isaac /*@
7419ef957cSToby Isaac   PetscLogHandlerSetState - Set the logging state that provides the stream of events and stages for a log handler.
7519ef957cSToby Isaac 
7619ef957cSToby Isaac   Logically collective
7719ef957cSToby Isaac 
7819ef957cSToby Isaac   Input Parameters:
7919ef957cSToby Isaac + h     - the `PetscLogHandler`
8019ef957cSToby Isaac - state - the `PetscLogState`
8119ef957cSToby Isaac 
8219ef957cSToby Isaac   Level: developer
8319ef957cSToby Isaac 
84b665b14eSToby Isaac   Note:
85b665b14eSToby Isaac   Most users well not need to set a state explicitly: the global logging state (`PetscLogGetState()`) is set when calling `PetscLogHandlerStart()`
86b665b14eSToby Isaac 
87b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogState`, `PetscLogEventBegin()`, `PetscLogHandlerStart()`
8819ef957cSToby Isaac @*/
8919ef957cSToby Isaac PetscErrorCode PetscLogHandlerSetState(PetscLogHandler h, PetscLogState state)
9019ef957cSToby Isaac {
9119ef957cSToby Isaac   PetscFunctionBegin;
9219ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
9319ef957cSToby Isaac   if (state) {
9419ef957cSToby Isaac     PetscAssertPointer(state, 2);
9519ef957cSToby Isaac     state->refct++;
9619ef957cSToby Isaac   }
9719ef957cSToby Isaac   PetscCall(PetscLogStateDestroy(&h->state));
9819ef957cSToby Isaac   h->state = state;
9919ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
10019ef957cSToby Isaac }
10119ef957cSToby Isaac 
10219ef957cSToby Isaac /*@
10319ef957cSToby Isaac   PetscLogHandlerGetState - Get the logging state that provides the stream of events and stages for a log handler.
10419ef957cSToby Isaac 
10519ef957cSToby Isaac   Logically collective
10619ef957cSToby Isaac 
10719ef957cSToby Isaac   Input Parameter:
10819ef957cSToby Isaac . h - the `PetscLogHandler`
10919ef957cSToby Isaac 
11019ef957cSToby Isaac   Output Parameter:
11119ef957cSToby Isaac . state - the `PetscLogState`
11219ef957cSToby Isaac 
11319ef957cSToby Isaac   Level: developer
11419ef957cSToby Isaac 
115b665b14eSToby Isaac   Note:
116b665b14eSToby Isaac   For a log handler started with `PetscLogHandlerStart()`, this will be the PETSc global logging state (`PetscLogGetState()`)
117b665b14eSToby Isaac 
118b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogState`, `PetscLogEventBegin()`, `PetscLogHandlerStart()`
11919ef957cSToby Isaac @*/
12019ef957cSToby Isaac PetscErrorCode PetscLogHandlerGetState(PetscLogHandler h, PetscLogState *state)
12119ef957cSToby Isaac {
12219ef957cSToby Isaac   PetscFunctionBegin;
12319ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
12419ef957cSToby Isaac   PetscAssertPointer(state, 2);
12519ef957cSToby Isaac   *state = h->state;
12619ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
12719ef957cSToby Isaac }
12819ef957cSToby Isaac 
12919ef957cSToby Isaac /*@
13019ef957cSToby Isaac   PetscLogHandlerEventBegin - Record the beginning of an event in a log handler
13119ef957cSToby Isaac 
13219ef957cSToby Isaac   Not collective
13319ef957cSToby Isaac 
13419ef957cSToby Isaac   Input Parameters:
13519ef957cSToby Isaac + h  - the `PetscLogHandler`
13619ef957cSToby Isaac . e  - a registered `PetscLogEvent`
13719ef957cSToby Isaac . o1 - `PetscObject` associated with the event (may be `NULL`)
13819ef957cSToby Isaac . o2 - `PetscObject` associated with the event (may be `NULL`)
13919ef957cSToby Isaac . o3 - `PetscObject` associated with the event (may be `NULL`)
14019ef957cSToby Isaac - o4 - `PetscObject` associated with the event (may be `NULL`)
14119ef957cSToby Isaac 
14219ef957cSToby Isaac   Level: developer
14319ef957cSToby Isaac 
144b665b14eSToby Isaac   Note:
145b665b14eSToby Isaac   Most users will use `PetscLogEventBegin()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`
146b665b14eSToby Isaac 
147b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventEnd()`, `PetscLogHandlerEventSync()`
14819ef957cSToby Isaac @*/
14919ef957cSToby Isaac PetscErrorCode PetscLogHandlerEventBegin(PetscLogHandler h, PetscLogEvent e, PetscObject o1, PetscObject o2, PetscObject o3, PetscObject o4)
15019ef957cSToby Isaac {
15119ef957cSToby Isaac   PetscFunctionBegin;
15219ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
15319ef957cSToby Isaac   PetscTryTypeMethod(h, eventbegin, e, o1, o2, o3, o4);
15419ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
15519ef957cSToby Isaac }
15619ef957cSToby Isaac 
15719ef957cSToby Isaac /*@
15819ef957cSToby Isaac   PetscLogHandlerEventEnd - Record the end of an event in a log handler
15919ef957cSToby Isaac 
16019ef957cSToby Isaac   Not collective
16119ef957cSToby Isaac 
16219ef957cSToby Isaac   Input Parameters:
16319ef957cSToby Isaac + h  - the `PetscLogHandler`
16419ef957cSToby Isaac . e  - a registered `PetscLogEvent`
16519ef957cSToby Isaac . o1 - `PetscObject` associated with the event (may be `NULL`)
16619ef957cSToby Isaac . o2 - `PetscObject` associated with the event (may be `NULL`)
16719ef957cSToby Isaac . o3 - `PetscObject` associated with the event (may be `NULL`)
16819ef957cSToby Isaac - o4 - `PetscObject` associated with the event (may be `NULL`)
16919ef957cSToby Isaac 
17019ef957cSToby Isaac   Level: developer
17119ef957cSToby Isaac 
172b665b14eSToby Isaac   Note:
173b665b14eSToby Isaac   Most users will use `PetscLogEventEnd()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`
174b665b14eSToby Isaac 
175b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventBegin()`, `PetscLogHandlerEventSync()`
17619ef957cSToby Isaac @*/
17719ef957cSToby Isaac PetscErrorCode PetscLogHandlerEventEnd(PetscLogHandler h, PetscLogEvent e, PetscObject o1, PetscObject o2, PetscObject o3, PetscObject o4)
17819ef957cSToby Isaac {
17919ef957cSToby Isaac   PetscFunctionBegin;
18019ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
18119ef957cSToby Isaac   PetscTryTypeMethod(h, eventend, e, o1, o2, o3, o4);
18219ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
18319ef957cSToby Isaac }
18419ef957cSToby Isaac 
18519ef957cSToby Isaac /*@
18619ef957cSToby Isaac   PetscLogHandlerEventSync - Synchronize a logging event
18719ef957cSToby Isaac 
18819ef957cSToby Isaac   Collective over comm
18919ef957cSToby Isaac 
19019ef957cSToby Isaac   Input Parameters:
19119ef957cSToby Isaac + h    - the `PetscLogHandler`
19219ef957cSToby Isaac . e    - a registered `PetscLogEvent`
19319ef957cSToby Isaac - comm - the communicator over which to synchronize `e`
19419ef957cSToby Isaac 
19519ef957cSToby Isaac   Level: developer
19619ef957cSToby Isaac 
197b665b14eSToby Isaac   Note:
198b665b14eSToby Isaac   Most users will use `PetscLogEventSync()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`
199b665b14eSToby Isaac 
200b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogEventSync()`, `PetscLogHandlerEventBegin()`, `PetscLogHandlerEventEnd()`
20119ef957cSToby Isaac @*/
20219ef957cSToby Isaac PetscErrorCode PetscLogHandlerEventSync(PetscLogHandler h, PetscLogEvent e, MPI_Comm comm)
20319ef957cSToby Isaac {
20419ef957cSToby Isaac   MPI_Comm    h_comm;
20519ef957cSToby Isaac   PetscMPIInt size;
20619ef957cSToby Isaac 
20719ef957cSToby Isaac   PetscFunctionBegin;
20819ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
20919ef957cSToby Isaac   PetscCall(PetscObjectGetComm((PetscObject)h, &h_comm));
21019ef957cSToby Isaac   PetscCallMPI(MPI_Comm_size(comm, &size));
21119ef957cSToby Isaac   if (comm == MPI_COMM_NULL || size == 1) PetscFunctionReturn(PETSC_SUCCESS); // nothing to sync
21219ef957cSToby Isaac   if (PetscDefined(USE_DEBUG)) {
21319ef957cSToby Isaac     PetscMPIInt h_comm_world, compare;
21419ef957cSToby Isaac     PetscCallMPI(MPI_Comm_compare(h_comm, PETSC_COMM_WORLD, &h_comm_world));
21519ef957cSToby Isaac     PetscCallMPI(MPI_Comm_compare(h_comm, comm, &compare));
21619ef957cSToby Isaac     // only synchronze if h->comm and comm have the same processes or h->comm is PETSC_COMM_WORLD
21719ef957cSToby Isaac     PetscCheck(h_comm_world != MPI_UNEQUAL || compare != MPI_UNEQUAL, comm, PETSC_ERR_SUP, "PetscLogHandlerSync does not support arbitrary mismatched communicators");
21819ef957cSToby Isaac   }
21919ef957cSToby Isaac   PetscTryTypeMethod(h, eventsync, e, comm);
22019ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
22119ef957cSToby Isaac }
22219ef957cSToby Isaac 
22319ef957cSToby Isaac /*@
22419ef957cSToby Isaac   PetscLogHandlerObjectCreate - Record the creation of an object in a log handler.
22519ef957cSToby Isaac 
22619ef957cSToby Isaac   Not collective
22719ef957cSToby Isaac 
22819ef957cSToby Isaac   Input Parameters:
22919ef957cSToby Isaac + h   - the `PetscLogHandler`
23019ef957cSToby Isaac - obj - a newly created `PetscObject`
23119ef957cSToby Isaac 
23219ef957cSToby Isaac   Level: developer
23319ef957cSToby Isaac 
234b665b14eSToby Isaac   Notes:
235b665b14eSToby Isaac   Most users will use `PetscLogObjectCreate()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`.
236b665b14eSToby Isaac 
237b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogHandlerObjectDestroy()`
23819ef957cSToby Isaac @*/
23919ef957cSToby Isaac PetscErrorCode PetscLogHandlerObjectCreate(PetscLogHandler h, PetscObject obj)
24019ef957cSToby Isaac {
24119ef957cSToby Isaac   PetscFunctionBegin;
24219ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
24319ef957cSToby Isaac   PetscTryTypeMethod(h, objectcreate, obj);
24419ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
24519ef957cSToby Isaac }
24619ef957cSToby Isaac 
24719ef957cSToby Isaac /*@
24819ef957cSToby Isaac   PetscLogHandlerObjectDestroy - Record the destruction of an object in a log handler.
24919ef957cSToby Isaac 
25019ef957cSToby Isaac   Not collective
25119ef957cSToby Isaac 
25219ef957cSToby Isaac   Input Parameters:
25319ef957cSToby Isaac + h   - the `PetscLogHandler`
25419ef957cSToby Isaac - obj - a newly created `PetscObject`
25519ef957cSToby Isaac 
25619ef957cSToby Isaac   Level: developer
25719ef957cSToby Isaac 
258b665b14eSToby Isaac   Notes:
259b665b14eSToby Isaac   Most users will use `PetscLogObjectDestroy()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`.
260b665b14eSToby Isaac 
261b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogHandlerObjectCreate()`
26219ef957cSToby Isaac @*/
26319ef957cSToby Isaac PetscErrorCode PetscLogHandlerObjectDestroy(PetscLogHandler h, PetscObject obj)
26419ef957cSToby Isaac {
26519ef957cSToby Isaac   PetscFunctionBegin;
26619ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
26719ef957cSToby Isaac   PetscTryTypeMethod(h, objectdestroy, obj);
26819ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
26919ef957cSToby Isaac }
27019ef957cSToby Isaac 
27119ef957cSToby Isaac /*@
27219ef957cSToby Isaac   PetscLogHandlerStagePush - Begin a new logging stage in a log handler.
27319ef957cSToby Isaac 
27419ef957cSToby Isaac   Not collective
27519ef957cSToby Isaac 
27619ef957cSToby Isaac   Input Parameters:
27719ef957cSToby Isaac + h     - the `PetscLogHandler`
27819ef957cSToby Isaac - stage - a registered `PetscLogStage`
27919ef957cSToby Isaac 
28019ef957cSToby Isaac   Level: developer
28119ef957cSToby Isaac 
28219ef957cSToby Isaac   Notes:
283b665b14eSToby Isaac   Most users will use `PetscLogStagePush()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`.
284b665b14eSToby Isaac 
28519ef957cSToby Isaac   This function is called right before the stage is pushed for the handler's `PetscLogState`, so `PetscLogStateGetCurrentStage()`
28619ef957cSToby Isaac   can be used to see what the previous stage was.
28719ef957cSToby Isaac 
288b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogHandlerStagePop()`
28919ef957cSToby Isaac @*/
29019ef957cSToby Isaac PetscErrorCode PetscLogHandlerStagePush(PetscLogHandler h, PetscLogStage stage)
29119ef957cSToby Isaac {
29219ef957cSToby Isaac   PetscFunctionBegin;
29319ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
29419ef957cSToby Isaac   PetscTryTypeMethod(h, stagepush, stage);
29519ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
29619ef957cSToby Isaac }
29719ef957cSToby Isaac 
29819ef957cSToby Isaac /*@
29919ef957cSToby Isaac   PetscLogHandlerStagePop - End the current logging stage in a log handler.
30019ef957cSToby Isaac 
30119ef957cSToby Isaac   Not collective
30219ef957cSToby Isaac 
30319ef957cSToby Isaac   Input Parameters:
30419ef957cSToby Isaac + h     - the `PetscLogHandler`
30519ef957cSToby Isaac - stage - a registered `PetscLogStage`
30619ef957cSToby Isaac 
30719ef957cSToby Isaac   Level: developer
30819ef957cSToby Isaac 
30919ef957cSToby Isaac   Notes:
310b665b14eSToby Isaac   Most users will use `PetscLogStagePop()`, which will call this function for all handlers registered with `PetscLogHandlerStart()`.
311b665b14eSToby Isaac 
31219ef957cSToby Isaac   This function is called right after the stage is popped for the handler's `PetscLogState`, so `PetscLogStateGetCurrentStage()`
31319ef957cSToby Isaac   can be used to see what the next stage will be.
31419ef957cSToby Isaac 
315b665b14eSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogHandlerStagePush()`
31619ef957cSToby Isaac @*/
31719ef957cSToby Isaac PetscErrorCode PetscLogHandlerStagePop(PetscLogHandler h, PetscLogStage stage)
31819ef957cSToby Isaac {
31919ef957cSToby Isaac   PetscFunctionBegin;
32019ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
32119ef957cSToby Isaac   PetscTryTypeMethod(h, stagepop, stage);
32219ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
32319ef957cSToby Isaac }
32419ef957cSToby Isaac 
32519ef957cSToby Isaac /*@
32619ef957cSToby Isaac   PetscLogHandlerView - View the data recorded in a log handler.
32719ef957cSToby Isaac 
32819ef957cSToby Isaac   Collective
32919ef957cSToby Isaac 
33019ef957cSToby Isaac   Input Parameters:
33119ef957cSToby Isaac + h      - the `PetscLogHandler`
33219ef957cSToby Isaac - viewer - the `PetscViewer`
33319ef957cSToby Isaac 
33419ef957cSToby Isaac   Level: developer
33519ef957cSToby Isaac 
33619ef957cSToby Isaac .seealso: [](ch_profiling), `PetscLogHandler`, `PetscLogView()`
33719ef957cSToby Isaac @*/
33819ef957cSToby Isaac PetscErrorCode PetscLogHandlerView(PetscLogHandler h, PetscViewer viewer)
33919ef957cSToby Isaac {
34019ef957cSToby Isaac   PetscFunctionBegin;
34119ef957cSToby Isaac   PetscValidHeaderSpecific(h, PETSCLOGHANDLER_CLASSID, 1);
34219ef957cSToby Isaac   PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 2);
34319ef957cSToby Isaac   PetscTryTypeMethod(h, view, viewer);
34419ef957cSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
34519ef957cSToby Isaac }
346dff009beSToby Isaac 
347dff009beSToby Isaac /*@C
348dff009beSToby Isaac   PetscLogHandlerGetEventPerfInfo - Get a direct reference to the `PetscEventPerfInfo` of a stage and event
349dff009beSToby Isaac 
350dff009beSToby Isaac   Not collective
351dff009beSToby Isaac 
352dff009beSToby Isaac   Input Parameters:
353dff009beSToby Isaac + handler - a `PetscLogHandler`
354dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
355dff009beSToby Isaac - event   - a `PetscLogEvent`
356dff009beSToby Isaac 
357dff009beSToby Isaac   Output Parameter:
358dff009beSToby Isaac . event_info - a pointer to a performance log for `event` during `stage` (or `NULL` if this handler does not use
359dff009beSToby Isaac                `PetscEventPerfInfo` to record performance data); writing to `event_info` will change the record in
360dff009beSToby Isaac                `handler`
361dff009beSToby Isaac 
362dff009beSToby Isaac   Level: developer
363dff009beSToby Isaac 
364dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogEventGetPerfInfo()`, `PETSCLOGHANDLERDEFAULT`
365dff009beSToby Isaac @*/
366dff009beSToby Isaac PetscErrorCode PetscLogHandlerGetEventPerfInfo(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event, PetscEventPerfInfo **event_info)
367dff009beSToby Isaac {
368dff009beSToby Isaac   PetscFunctionBegin;
369dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
370dff009beSToby Isaac   PetscAssertPointer(event_info, 4);
371dff009beSToby Isaac   *event_info = NULL;
372dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerGetEventPerfInfo_C", (PetscLogHandler, PetscLogStage, PetscLogEvent, PetscEventPerfInfo **), (handler, stage, event, event_info));
373dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
374dff009beSToby Isaac }
375dff009beSToby Isaac 
376*8b08f494SToby Isaac /*@C
377*8b08f494SToby Isaac   PetscLogHandlerGetStagePerfInfo - Get a direct reference to the `PetscEventPerfInfo` of a stage
378*8b08f494SToby Isaac 
379*8b08f494SToby Isaac   Not collective
380*8b08f494SToby Isaac 
381*8b08f494SToby Isaac   Input Parameters:
382*8b08f494SToby Isaac + handler - a `PetscLogHandler`
383*8b08f494SToby Isaac - stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
384*8b08f494SToby Isaac 
385*8b08f494SToby Isaac   Output Parameter:
386*8b08f494SToby Isaac . stage_info - a pointer to a performance log for `stage` (or `NULL` if this handler does not use `PetscEventPerfInfo`
387*8b08f494SToby Isaac                to record performance data); writing to `stage_info` will change the record in `handler`
388*8b08f494SToby Isaac 
389*8b08f494SToby Isaac   Level: developer
390*8b08f494SToby Isaac 
391*8b08f494SToby Isaac .seealso: [](ch_profiling), `PetscLogEventGetPerfInfo()`, `PETSCLOGHANDLERDEFAULT`
392*8b08f494SToby Isaac @*/
393*8b08f494SToby Isaac PetscErrorCode PetscLogHandlerGetStagePerfInfo(PetscLogHandler handler, PetscLogStage stage, PetscEventPerfInfo **stage_info)
394*8b08f494SToby Isaac {
395*8b08f494SToby Isaac   PetscFunctionBegin;
396*8b08f494SToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
397*8b08f494SToby Isaac   PetscAssertPointer(stage_info, 3);
398*8b08f494SToby Isaac   *stage_info = NULL;
399*8b08f494SToby Isaac   PetscTryMethod(handler, "PetscLogHandlerGetStagePerfInfo_C", (PetscLogHandler, PetscLogStage, PetscEventPerfInfo **), (handler, stage, stage_info));
400*8b08f494SToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
401*8b08f494SToby Isaac }
402*8b08f494SToby Isaac 
403dff009beSToby Isaac /*@
404dff009beSToby Isaac   PetscLogHandlerSetLogActions - Determines whether actions are logged for a log handler.
405dff009beSToby Isaac 
406dff009beSToby Isaac   Not Collective
407dff009beSToby Isaac 
408dff009beSToby Isaac   Input Parameters:
409dff009beSToby Isaac + handler - a `PetscLogHandler`
410dff009beSToby Isaac - flag    - `PETSC_TRUE` if actions are to be logged (ignored if `handler` does not log actions)
411dff009beSToby Isaac 
412dff009beSToby Isaac   Level: developer
413dff009beSToby Isaac 
414dff009beSToby Isaac   Notes:
415dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
416dff009beSToby Isaac   `PetscLogSetLogActions()` to call this function for the default log handler that is connected to the global
417dff009beSToby Isaac   logging state (`PetscLogGetState()`).
418dff009beSToby Isaac 
419dff009beSToby Isaac   Logging of actions continues to consume more memory as the program runs. Long running programs should consider
420dff009beSToby Isaac   turning this feature off.
421dff009beSToby Isaac 
422dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogSetLogActions()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()`
423dff009beSToby Isaac @*/
424dff009beSToby Isaac PetscErrorCode PetscLogHandlerSetLogActions(PetscLogHandler handler, PetscBool flag)
425dff009beSToby Isaac {
426dff009beSToby Isaac   PetscFunctionBegin;
427dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
428dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerSetLogActions_C", (PetscLogHandler, PetscBool), (handler, flag));
429dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
430dff009beSToby Isaac }
431dff009beSToby Isaac 
432dff009beSToby Isaac /*@
433dff009beSToby Isaac   PetscLogHandlerSetLogObjects - Determines whether objects are logged for a log handler.
434dff009beSToby Isaac 
435dff009beSToby Isaac   Not Collective
436dff009beSToby Isaac 
437dff009beSToby Isaac   Input Parameters:
438dff009beSToby Isaac + handler - a `PetscLogHandler`
439dff009beSToby Isaac - flag    - `PETSC_TRUE` if objects are to be logged (ignored if `handler` does not log objects)
440dff009beSToby Isaac 
441dff009beSToby Isaac   Level: developer
442dff009beSToby Isaac 
443dff009beSToby Isaac   Notes:
444dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
445dff009beSToby Isaac   `PetscLogSetLogObjects()` to call this function for the default log handler that is connected to the global
446dff009beSToby Isaac   logging state (`PetscLogGetState()`).
447dff009beSToby Isaac 
448dff009beSToby Isaac   Logging of objects continues to consume more memory as the program runs. Long running programs should consider
449dff009beSToby Isaac   turning this feature off.
450dff009beSToby Isaac 
451dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogSetLogObjects()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()`
452dff009beSToby Isaac @*/
453dff009beSToby Isaac PetscErrorCode PetscLogHandlerSetLogObjects(PetscLogHandler handler, PetscBool flag)
454dff009beSToby Isaac {
455dff009beSToby Isaac   PetscFunctionBegin;
456dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
457dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerSetLogObjects_C", (PetscLogHandler, PetscBool), (handler, flag));
458dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
459dff009beSToby Isaac }
460dff009beSToby Isaac 
461dff009beSToby Isaac PetscErrorCode PetscLogHandlerLogObjectState_Internal(PetscLogHandler handler, PetscObject obj, const char format[], va_list argp)
462dff009beSToby Isaac {
463dff009beSToby Isaac   PetscFunctionBegin;
464dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerLogObjectState_C", (PetscLogHandler, PetscObject, const char *, va_list), (handler, obj, format, argp));
465dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
466dff009beSToby Isaac }
467dff009beSToby Isaac 
468dff009beSToby Isaac /*@C
469dff009beSToby Isaac   PetscLogHandlerLogObjectState - Record information about an object with the default log handler
470dff009beSToby Isaac 
471dff009beSToby Isaac   Not Collective
472dff009beSToby Isaac 
473dff009beSToby Isaac   Input Parameters:
474dff009beSToby Isaac + handler - a `PetscLogHandler`
475dff009beSToby Isaac . obj     - the `PetscObject`
476dff009beSToby Isaac . format  - a printf-style format string
477dff009beSToby Isaac - ...     - printf arguments to format
478dff009beSToby Isaac 
479dff009beSToby Isaac   Level: developer
480dff009beSToby Isaac 
481dff009beSToby Isaac   Note:
482dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
483dff009beSToby Isaac   `PetscLogObjectState()` to call this function for the default log handler that is connected to the global
484dff009beSToby Isaac   logging state (`PetscLogGetState()`).
485dff009beSToby Isaac 
486dff009beSToby Isaac .seealso: [](ch_profiling), `PetcLogObjectState`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogGetDefaultHandler()`
487dff009beSToby Isaac @*/
488dff009beSToby Isaac PetscErrorCode PetscLogHandlerLogObjectState(PetscLogHandler handler, PetscObject obj, const char format[], ...)
489dff009beSToby Isaac {
490dff009beSToby Isaac   va_list argp;
491dff009beSToby Isaac 
492dff009beSToby Isaac   PetscFunctionBegin;
493dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
494dff009beSToby Isaac   PetscValidHeader(obj, 2);
495dff009beSToby Isaac   PetscAssertPointer(format, 3);
496dff009beSToby Isaac   va_start(argp, format);
497dff009beSToby Isaac   PetscCall(PetscLogHandlerLogObjectState_Internal(handler, obj, format, argp));
498dff009beSToby Isaac   va_end(argp);
499dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
500dff009beSToby Isaac }
501dff009beSToby Isaac 
502dff009beSToby Isaac /*@
503dff009beSToby Isaac   PetscLogHandlerGetNumObjects - Get the number of objects that were logged with a log handler
504dff009beSToby Isaac 
505dff009beSToby Isaac   Not Collective
506dff009beSToby Isaac 
507dff009beSToby Isaac   Input Parameter:
508dff009beSToby Isaac . handler - a `PetscLogHandler`
509dff009beSToby Isaac 
510dff009beSToby Isaac   Output Parameter:
511dff009beSToby Isaac . num_objects - the number of objects whose creations and destructions were logged with `handler`
512dff009beSToby Isaac                 (`PetscLogHandlerObjectCreate()` / `PetscLogHandlerObjectDestroy()`), or -1
513dff009beSToby Isaac                 if the handler does not keep track of this number.
514dff009beSToby Isaac 
515dff009beSToby Isaac   Level: developer
516dff009beSToby Isaac 
517dff009beSToby Isaac   Note:
518dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.
519dff009beSToby Isaac 
520dff009beSToby Isaac .seealso: [](ch_profiling)
521dff009beSToby Isaac @*/
522dff009beSToby Isaac PetscErrorCode PetscLogHandlerGetNumObjects(PetscLogHandler handler, PetscInt *num_objects)
523dff009beSToby Isaac {
524dff009beSToby Isaac   PetscFunctionBegin;
525dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
526dff009beSToby Isaac   PetscAssertPointer(num_objects, 2);
527dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerGetNumObjects_C", (PetscLogHandler, PetscInt *), (handler, num_objects));
528dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
529dff009beSToby Isaac }
530dff009beSToby Isaac 
531dff009beSToby Isaac /*@
532dff009beSToby Isaac   PetscLogHandlerEventDeactivatePush - Temporarily deactivate a logging event for a log handler
533dff009beSToby Isaac 
534dff009beSToby Isaac   Not collective
535dff009beSToby Isaac 
536dff009beSToby Isaac   Input Parameters:
537dff009beSToby Isaac + handler - a `PetscLogHandler`
538dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
539dff009beSToby Isaac - event   - a `PetscLogEvent`
540dff009beSToby Isaac 
541dff009beSToby Isaac   Level: developer
542dff009beSToby Isaac 
543dff009beSToby Isaac   Note:
544dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
545dff009beSToby Isaac   `PetscLogEventDeactivatePush()` to call this function for the default log handler that is connected to the global
546dff009beSToby Isaac   logging state (`PetscLogGetState()`).
547dff009beSToby Isaac 
548dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePop()`
549dff009beSToby Isaac @*/
550dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventDeactivatePush(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event)
551dff009beSToby Isaac {
552dff009beSToby Isaac   PetscFunctionBegin;
553dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
554dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePush_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event));
555dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
556dff009beSToby Isaac }
557dff009beSToby Isaac 
558dff009beSToby Isaac /*@
559dff009beSToby Isaac   PetscLogHandlerEventDeactivatePop - Undo temporary deactivation a logging event for a log handler
560dff009beSToby Isaac 
561dff009beSToby Isaac   Not collective
562dff009beSToby Isaac 
563dff009beSToby Isaac   Input Parameters:
564dff009beSToby Isaac + handler - a `PetscLogHandler`
565dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
566dff009beSToby Isaac - event   - a `PetscLogEvent`
567dff009beSToby Isaac 
568dff009beSToby Isaac   Level: developer
569dff009beSToby Isaac 
570dff009beSToby Isaac   Note:
571dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
572dff009beSToby Isaac   `PetscLogEventDeactivatePop()` to call this function for the default log handler that is connected to the global
573dff009beSToby Isaac   logging state (`PetscLogGetState()`).
574dff009beSToby Isaac 
575dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePush()`
576dff009beSToby Isaac @*/
577dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventDeactivatePop(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event)
578dff009beSToby Isaac {
579dff009beSToby Isaac   PetscFunctionBegin;
580dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
581dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePop_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event));
582dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
583dff009beSToby Isaac }
584dff009beSToby Isaac 
585dff009beSToby Isaac /*@
586dff009beSToby Isaac   PetscLogHandlerEventsPause - Put event logging into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler
587dff009beSToby Isaac 
588dff009beSToby Isaac   Not collective
589dff009beSToby Isaac 
590dff009beSToby Isaac   Input Parameter:
591dff009beSToby Isaac . handler - a `PetscLogHandler`
592dff009beSToby Isaac 
593dff009beSToby Isaac   Level: developer
594dff009beSToby Isaac 
595dff009beSToby Isaac   Note:
596dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
597dff009beSToby Isaac   `PetscLogEventsPause()` to call this function for the default log handler that is connected to the global
598dff009beSToby Isaac   logging state (`PetscLogGetState()`).
599dff009beSToby Isaac 
600dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventsResume()`
601dff009beSToby Isaac @*/
602dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventsPause(PetscLogHandler handler)
603dff009beSToby Isaac {
604dff009beSToby Isaac   PetscFunctionBegin;
605dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
606dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventsPause_C", (PetscLogHandler), (handler));
607dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
608dff009beSToby Isaac }
609dff009beSToby Isaac 
610dff009beSToby Isaac /*@
611dff009beSToby Isaac   PetscLogHandlerEventsResume - Resume event logging that had been put into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler
612dff009beSToby Isaac 
613dff009beSToby Isaac   Not collective
614dff009beSToby Isaac 
615dff009beSToby Isaac   Input Parameter:
616dff009beSToby Isaac . handler - a `PetscLogHandler`
617dff009beSToby Isaac 
618dff009beSToby Isaac   Level: developer
619dff009beSToby Isaac 
620dff009beSToby Isaac   Note:
621dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
622dff009beSToby Isaac   `PetscLogEventsResume()` to call this function for the default log handler that is connected to the global
623dff009beSToby Isaac   logging state (`PetscLogGetState()`).
624dff009beSToby Isaac 
625dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventsPause()`
626dff009beSToby Isaac @*/
627dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventsResume(PetscLogHandler handler)
628dff009beSToby Isaac {
629dff009beSToby Isaac   PetscFunctionBegin;
630dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
631dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventsResume_C", (PetscLogHandler), (handler));
632dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
633dff009beSToby Isaac }
634dff009beSToby Isaac 
635dff009beSToby Isaac /*@
636dff009beSToby Isaac   PetscLogHandlerDump - Dump the records of a log handler to file
637dff009beSToby Isaac 
638dff009beSToby Isaac   Not collective
639dff009beSToby Isaac 
640dff009beSToby Isaac   Input Parameters:
641dff009beSToby Isaac + handler - a `PetscLogHandler`
642dff009beSToby Isaac - sname   - the name of the file to dump log data to
643dff009beSToby Isaac 
644dff009beSToby Isaac   Level: developer
645dff009beSToby Isaac 
646dff009beSToby Isaac   Note:
647dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
648dff009beSToby Isaac   `PetscLogDump()` to call this function for the default log handler that is connected to the global
649dff009beSToby Isaac   logging state (`PetscLogGetState()`).
650dff009beSToby Isaac 
651dff009beSToby Isaac .seealso: [](ch_profiling)
652dff009beSToby Isaac @*/
653dff009beSToby Isaac PetscErrorCode PetscLogHandlerDump(PetscLogHandler handler, const char sname[])
654dff009beSToby Isaac {
655dff009beSToby Isaac   PetscFunctionBegin;
656dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerDump_C", (PetscLogHandler, const char *), (handler, sname));
657dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
658dff009beSToby Isaac }
659dff009beSToby Isaac 
660dff009beSToby Isaac /*@
661dff009beSToby Isaac   PetscLogHandlerStageSetVisible - Set the visiblity of logging stage in `PetscLogHandlerView()` for a log handler
662dff009beSToby Isaac 
663dff009beSToby Isaac   Not collective
664dff009beSToby Isaac 
665dff009beSToby Isaac   Input Parameters:
666dff009beSToby Isaac + handler   - a `PetscLogHandler`
667dff009beSToby Isaac . stage     - a `PetscLogStage`
668dff009beSToby Isaac - isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`)
669dff009beSToby Isaac 
670dff009beSToby Isaac   Level: developer
671dff009beSToby Isaac 
672dff009beSToby Isaac   Note:
673dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
674dff009beSToby Isaac   `PetscLogStageSetVisible()` to call this function for the default log handler that is connected to the global
675dff009beSToby Isaac   logging state (`PetscLogGetState()`).
676dff009beSToby Isaac 
677dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerStageGetVisible()`
678dff009beSToby Isaac @*/
679dff009beSToby Isaac PetscErrorCode PetscLogHandlerStageSetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool isVisible)
680dff009beSToby Isaac {
681dff009beSToby Isaac   PetscFunctionBegin;
682dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
683dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerStageSetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool), (handler, stage, isVisible));
684dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
685dff009beSToby Isaac }
686dff009beSToby Isaac 
687dff009beSToby Isaac /*@
688dff009beSToby Isaac   PetscLogHandlerStageGetVisible - Get the visiblity of logging stage in `PetscLogHandlerView()` for a log handler
689dff009beSToby Isaac 
690dff009beSToby Isaac   Not collective
691dff009beSToby Isaac 
692dff009beSToby Isaac   Input Parameters:
693dff009beSToby Isaac + handler - a `PetscLogHandler`
694dff009beSToby Isaac - stage   - a `PetscLogStage`
695dff009beSToby Isaac 
696dff009beSToby Isaac   Output Parameter:
697dff009beSToby Isaac . isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`)
698dff009beSToby Isaac 
699dff009beSToby Isaac   Level: developer
700dff009beSToby Isaac 
701dff009beSToby Isaac   Note:
702dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
703dff009beSToby Isaac   `PetscLogStageGetVisible()` to call this function for the default log handler that is connected to the global
704dff009beSToby Isaac   logging state (`PetscLogGetState()`).
705dff009beSToby Isaac 
706dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerStageSetVisible()`
707dff009beSToby Isaac @*/
708dff009beSToby Isaac PetscErrorCode PetscLogHandlerStageGetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool *isVisible)
709dff009beSToby Isaac {
710dff009beSToby Isaac   PetscFunctionBegin;
711dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
712dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerStageGetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool *), (handler, stage, isVisible));
713dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
714dff009beSToby Isaac }
715