xref: /petsc/src/sys/logging/handler/interface/loghandler.c (revision dff009be1503132eb32dbaedc8512f49b68e5e4c)
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>
5*dff009beSToby 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 }
346*dff009beSToby Isaac 
347*dff009beSToby Isaac /*@C
348*dff009beSToby Isaac   PetscLogHandlerGetEventPerfInfo - Get a direct reference to the `PetscEventPerfInfo` of a stage and event
349*dff009beSToby Isaac 
350*dff009beSToby Isaac   Not collective
351*dff009beSToby Isaac 
352*dff009beSToby Isaac   Input Parameters:
353*dff009beSToby Isaac + handler - a `PetscLogHandler`
354*dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
355*dff009beSToby Isaac - event   - a `PetscLogEvent`
356*dff009beSToby Isaac 
357*dff009beSToby Isaac   Output Parameter:
358*dff009beSToby Isaac . event_info - a pointer to a performance log for `event` during `stage` (or `NULL` if this handler does not use
359*dff009beSToby Isaac                `PetscEventPerfInfo` to record performance data); writing to `event_info` will change the record in
360*dff009beSToby Isaac                `handler`
361*dff009beSToby Isaac 
362*dff009beSToby Isaac   Level: developer
363*dff009beSToby Isaac 
364*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogEventGetPerfInfo()`, `PETSCLOGHANDLERDEFAULT`
365*dff009beSToby Isaac @*/
366*dff009beSToby Isaac PetscErrorCode PetscLogHandlerGetEventPerfInfo(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event, PetscEventPerfInfo **event_info)
367*dff009beSToby Isaac {
368*dff009beSToby Isaac   PetscFunctionBegin;
369*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
370*dff009beSToby Isaac   PetscAssertPointer(event_info, 4);
371*dff009beSToby Isaac   *event_info = NULL;
372*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerGetEventPerfInfo_C", (PetscLogHandler, PetscLogStage, PetscLogEvent, PetscEventPerfInfo **), (handler, stage, event, event_info));
373*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
374*dff009beSToby Isaac }
375*dff009beSToby Isaac 
376*dff009beSToby Isaac /*@
377*dff009beSToby Isaac   PetscLogHandlerSetLogActions - Determines whether actions are logged for a log handler.
378*dff009beSToby Isaac 
379*dff009beSToby Isaac   Not Collective
380*dff009beSToby Isaac 
381*dff009beSToby Isaac   Input Parameters:
382*dff009beSToby Isaac + handler - a `PetscLogHandler`
383*dff009beSToby Isaac - flag    - `PETSC_TRUE` if actions are to be logged (ignored if `handler` does not log actions)
384*dff009beSToby Isaac 
385*dff009beSToby Isaac   Level: developer
386*dff009beSToby Isaac 
387*dff009beSToby Isaac   Notes:
388*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
389*dff009beSToby Isaac   `PetscLogSetLogActions()` to call this function for the default log handler that is connected to the global
390*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
391*dff009beSToby Isaac 
392*dff009beSToby Isaac   Logging of actions continues to consume more memory as the program runs. Long running programs should consider
393*dff009beSToby Isaac   turning this feature off.
394*dff009beSToby Isaac 
395*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogSetLogActions()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()`
396*dff009beSToby Isaac @*/
397*dff009beSToby Isaac PetscErrorCode PetscLogHandlerSetLogActions(PetscLogHandler handler, PetscBool flag)
398*dff009beSToby Isaac {
399*dff009beSToby Isaac   PetscFunctionBegin;
400*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
401*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerSetLogActions_C", (PetscLogHandler, PetscBool), (handler, flag));
402*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
403*dff009beSToby Isaac }
404*dff009beSToby Isaac 
405*dff009beSToby Isaac /*@
406*dff009beSToby Isaac   PetscLogHandlerSetLogObjects - Determines whether objects are logged for a log handler.
407*dff009beSToby Isaac 
408*dff009beSToby Isaac   Not Collective
409*dff009beSToby Isaac 
410*dff009beSToby Isaac   Input Parameters:
411*dff009beSToby Isaac + handler - a `PetscLogHandler`
412*dff009beSToby Isaac - flag    - `PETSC_TRUE` if objects are to be logged (ignored if `handler` does not log objects)
413*dff009beSToby Isaac 
414*dff009beSToby Isaac   Level: developer
415*dff009beSToby Isaac 
416*dff009beSToby Isaac   Notes:
417*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
418*dff009beSToby Isaac   `PetscLogSetLogObjects()` to call this function for the default log handler that is connected to the global
419*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
420*dff009beSToby Isaac 
421*dff009beSToby Isaac   Logging of objects continues to consume more memory as the program runs. Long running programs should consider
422*dff009beSToby Isaac   turning this feature off.
423*dff009beSToby Isaac 
424*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogSetLogObjects()`, `PetscLogStagePush()`, `PetscLogStagePop()`, `PetscLogGetDefaultHandler()`
425*dff009beSToby Isaac @*/
426*dff009beSToby Isaac PetscErrorCode PetscLogHandlerSetLogObjects(PetscLogHandler handler, PetscBool flag)
427*dff009beSToby Isaac {
428*dff009beSToby Isaac   PetscFunctionBegin;
429*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
430*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerSetLogObjects_C", (PetscLogHandler, PetscBool), (handler, flag));
431*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
432*dff009beSToby Isaac }
433*dff009beSToby Isaac 
434*dff009beSToby Isaac PetscErrorCode PetscLogHandlerLogObjectState_Internal(PetscLogHandler handler, PetscObject obj, const char format[], va_list argp)
435*dff009beSToby Isaac {
436*dff009beSToby Isaac   PetscFunctionBegin;
437*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerLogObjectState_C", (PetscLogHandler, PetscObject, const char *, va_list), (handler, obj, format, argp));
438*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
439*dff009beSToby Isaac }
440*dff009beSToby Isaac 
441*dff009beSToby Isaac /*@C
442*dff009beSToby Isaac   PetscLogHandlerLogObjectState - Record information about an object with the default log handler
443*dff009beSToby Isaac 
444*dff009beSToby Isaac   Not Collective
445*dff009beSToby Isaac 
446*dff009beSToby Isaac   Input Parameters:
447*dff009beSToby Isaac + handler - a `PetscLogHandler`
448*dff009beSToby Isaac . obj     - the `PetscObject`
449*dff009beSToby Isaac . format  - a printf-style format string
450*dff009beSToby Isaac - ...     - printf arguments to format
451*dff009beSToby Isaac 
452*dff009beSToby Isaac   Level: developer
453*dff009beSToby Isaac 
454*dff009beSToby Isaac   Note:
455*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
456*dff009beSToby Isaac   `PetscLogObjectState()` to call this function for the default log handler that is connected to the global
457*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
458*dff009beSToby Isaac 
459*dff009beSToby Isaac .seealso: [](ch_profiling), `PetcLogObjectState`, `PetscLogObjectCreate()`, `PetscLogObjectDestroy()`, `PetscLogGetDefaultHandler()`
460*dff009beSToby Isaac @*/
461*dff009beSToby Isaac PetscErrorCode PetscLogHandlerLogObjectState(PetscLogHandler handler, PetscObject obj, const char format[], ...)
462*dff009beSToby Isaac {
463*dff009beSToby Isaac   va_list argp;
464*dff009beSToby Isaac 
465*dff009beSToby Isaac   PetscFunctionBegin;
466*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
467*dff009beSToby Isaac   PetscValidHeader(obj, 2);
468*dff009beSToby Isaac   PetscAssertPointer(format, 3);
469*dff009beSToby Isaac   va_start(argp, format);
470*dff009beSToby Isaac   PetscCall(PetscLogHandlerLogObjectState_Internal(handler, obj, format, argp));
471*dff009beSToby Isaac   va_end(argp);
472*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
473*dff009beSToby Isaac }
474*dff009beSToby Isaac 
475*dff009beSToby Isaac /*@
476*dff009beSToby Isaac   PetscLogHandlerGetNumObjects - Get the number of objects that were logged with a log handler
477*dff009beSToby Isaac 
478*dff009beSToby Isaac   Not Collective
479*dff009beSToby Isaac 
480*dff009beSToby Isaac   Input Parameter:
481*dff009beSToby Isaac . handler - a `PetscLogHandler`
482*dff009beSToby Isaac 
483*dff009beSToby Isaac   Output Parameter:
484*dff009beSToby Isaac . num_objects - the number of objects whose creations and destructions were logged with `handler`
485*dff009beSToby Isaac                 (`PetscLogHandlerObjectCreate()` / `PetscLogHandlerObjectDestroy()`), or -1
486*dff009beSToby Isaac                 if the handler does not keep track of this number.
487*dff009beSToby Isaac 
488*dff009beSToby Isaac   Level: developer
489*dff009beSToby Isaac 
490*dff009beSToby Isaac   Note:
491*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.
492*dff009beSToby Isaac 
493*dff009beSToby Isaac .seealso: [](ch_profiling)
494*dff009beSToby Isaac @*/
495*dff009beSToby Isaac PetscErrorCode PetscLogHandlerGetNumObjects(PetscLogHandler handler, PetscInt *num_objects)
496*dff009beSToby Isaac {
497*dff009beSToby Isaac   PetscFunctionBegin;
498*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
499*dff009beSToby Isaac   PetscAssertPointer(num_objects, 2);
500*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerGetNumObjects_C", (PetscLogHandler, PetscInt *), (handler, num_objects));
501*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
502*dff009beSToby Isaac }
503*dff009beSToby Isaac 
504*dff009beSToby Isaac /*@
505*dff009beSToby Isaac   PetscLogHandlerEventDeactivatePush - Temporarily deactivate a logging event for a log handler
506*dff009beSToby Isaac 
507*dff009beSToby Isaac   Not collective
508*dff009beSToby Isaac 
509*dff009beSToby Isaac   Input Parameters:
510*dff009beSToby Isaac + handler - a `PetscLogHandler`
511*dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
512*dff009beSToby Isaac - event   - a `PetscLogEvent`
513*dff009beSToby Isaac 
514*dff009beSToby Isaac   Level: developer
515*dff009beSToby Isaac 
516*dff009beSToby Isaac   Note:
517*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
518*dff009beSToby Isaac   `PetscLogEventDeactivatePush()` to call this function for the default log handler that is connected to the global
519*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
520*dff009beSToby Isaac 
521*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePop()`
522*dff009beSToby Isaac @*/
523*dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventDeactivatePush(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event)
524*dff009beSToby Isaac {
525*dff009beSToby Isaac   PetscFunctionBegin;
526*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
527*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePush_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event));
528*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
529*dff009beSToby Isaac }
530*dff009beSToby Isaac 
531*dff009beSToby Isaac /*@
532*dff009beSToby Isaac   PetscLogHandlerEventDeactivatePop - Undo temporary deactivation a logging event for a log handler
533*dff009beSToby Isaac 
534*dff009beSToby Isaac   Not collective
535*dff009beSToby Isaac 
536*dff009beSToby Isaac   Input Parameters:
537*dff009beSToby Isaac + handler - a `PetscLogHandler`
538*dff009beSToby Isaac . stage   - a `PetscLogStage` (or `PETSC_DEFAULT` for the current stage)
539*dff009beSToby Isaac - event   - a `PetscLogEvent`
540*dff009beSToby Isaac 
541*dff009beSToby Isaac   Level: developer
542*dff009beSToby Isaac 
543*dff009beSToby Isaac   Note:
544*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
545*dff009beSToby Isaac   `PetscLogEventDeactivatePop()` to call this function for the default log handler that is connected to the global
546*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
547*dff009beSToby Isaac 
548*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventDeactivatePush()`
549*dff009beSToby Isaac @*/
550*dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventDeactivatePop(PetscLogHandler handler, PetscLogStage stage, PetscLogEvent event)
551*dff009beSToby Isaac {
552*dff009beSToby Isaac   PetscFunctionBegin;
553*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
554*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventDeactivatePop_C", (PetscLogHandler, PetscLogStage, PetscLogEvent), (handler, stage, event));
555*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
556*dff009beSToby Isaac }
557*dff009beSToby Isaac 
558*dff009beSToby Isaac /*@
559*dff009beSToby Isaac   PetscLogHandlerEventsPause - Put event logging into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler
560*dff009beSToby Isaac 
561*dff009beSToby Isaac   Not collective
562*dff009beSToby Isaac 
563*dff009beSToby Isaac   Input Parameter:
564*dff009beSToby Isaac . handler - a `PetscLogHandler`
565*dff009beSToby Isaac 
566*dff009beSToby Isaac   Level: developer
567*dff009beSToby Isaac 
568*dff009beSToby Isaac   Note:
569*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
570*dff009beSToby Isaac   `PetscLogEventsPause()` to call this function for the default log handler that is connected to the global
571*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
572*dff009beSToby Isaac 
573*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventsResume()`
574*dff009beSToby Isaac @*/
575*dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventsPause(PetscLogHandler handler)
576*dff009beSToby Isaac {
577*dff009beSToby Isaac   PetscFunctionBegin;
578*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
579*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventsPause_C", (PetscLogHandler), (handler));
580*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
581*dff009beSToby Isaac }
582*dff009beSToby Isaac 
583*dff009beSToby Isaac /*@
584*dff009beSToby Isaac   PetscLogHandlerEventsResume - Resume event logging that had been put into "paused" mode (see `PetscLogEventsPause()` for details.) for a log handler
585*dff009beSToby Isaac 
586*dff009beSToby Isaac   Not collective
587*dff009beSToby Isaac 
588*dff009beSToby Isaac   Input Parameter:
589*dff009beSToby Isaac . handler - a `PetscLogHandler`
590*dff009beSToby Isaac 
591*dff009beSToby Isaac   Level: developer
592*dff009beSToby Isaac 
593*dff009beSToby Isaac   Note:
594*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
595*dff009beSToby Isaac   `PetscLogEventsResume()` to call this function for the default log handler that is connected to the global
596*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
597*dff009beSToby Isaac 
598*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerEventsPause()`
599*dff009beSToby Isaac @*/
600*dff009beSToby Isaac PetscErrorCode PetscLogHandlerEventsResume(PetscLogHandler handler)
601*dff009beSToby Isaac {
602*dff009beSToby Isaac   PetscFunctionBegin;
603*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
604*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerEventsResume_C", (PetscLogHandler), (handler));
605*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
606*dff009beSToby Isaac }
607*dff009beSToby Isaac 
608*dff009beSToby Isaac /*@
609*dff009beSToby Isaac   PetscLogHandlerDump - Dump the records of a log handler to file
610*dff009beSToby Isaac 
611*dff009beSToby Isaac   Not collective
612*dff009beSToby Isaac 
613*dff009beSToby Isaac   Input Parameters:
614*dff009beSToby Isaac + handler - a `PetscLogHandler`
615*dff009beSToby Isaac - sname   - the name of the file to dump log data to
616*dff009beSToby Isaac 
617*dff009beSToby Isaac   Level: developer
618*dff009beSToby Isaac 
619*dff009beSToby Isaac   Note:
620*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
621*dff009beSToby Isaac   `PetscLogDump()` to call this function for the default log handler that is connected to the global
622*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
623*dff009beSToby Isaac 
624*dff009beSToby Isaac .seealso: [](ch_profiling)
625*dff009beSToby Isaac @*/
626*dff009beSToby Isaac PetscErrorCode PetscLogHandlerDump(PetscLogHandler handler, const char sname[])
627*dff009beSToby Isaac {
628*dff009beSToby Isaac   PetscFunctionBegin;
629*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerDump_C", (PetscLogHandler, const char *), (handler, sname));
630*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
631*dff009beSToby Isaac }
632*dff009beSToby Isaac 
633*dff009beSToby Isaac /*@
634*dff009beSToby Isaac   PetscLogHandlerStageSetVisible - Set the visiblity of logging stage in `PetscLogHandlerView()` for a log handler
635*dff009beSToby Isaac 
636*dff009beSToby Isaac   Not collective
637*dff009beSToby Isaac 
638*dff009beSToby Isaac   Input Parameters:
639*dff009beSToby Isaac + handler   - a `PetscLogHandler`
640*dff009beSToby Isaac . stage     - a `PetscLogStage`
641*dff009beSToby Isaac - isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`)
642*dff009beSToby Isaac 
643*dff009beSToby Isaac   Level: developer
644*dff009beSToby Isaac 
645*dff009beSToby Isaac   Note:
646*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
647*dff009beSToby Isaac   `PetscLogStageSetVisible()` to call this function for the default log handler that is connected to the global
648*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
649*dff009beSToby Isaac 
650*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerStageGetVisible()`
651*dff009beSToby Isaac @*/
652*dff009beSToby Isaac PetscErrorCode PetscLogHandlerStageSetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool isVisible)
653*dff009beSToby Isaac {
654*dff009beSToby Isaac   PetscFunctionBegin;
655*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
656*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerStageSetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool), (handler, stage, isVisible));
657*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
658*dff009beSToby Isaac }
659*dff009beSToby Isaac 
660*dff009beSToby Isaac /*@
661*dff009beSToby Isaac   PetscLogHandlerStageGetVisible - Get the visiblity of logging stage in `PetscLogHandlerView()` for a log handler
662*dff009beSToby Isaac 
663*dff009beSToby Isaac   Not collective
664*dff009beSToby Isaac 
665*dff009beSToby Isaac   Input Parameters:
666*dff009beSToby Isaac + handler - a `PetscLogHandler`
667*dff009beSToby Isaac - stage   - a `PetscLogStage`
668*dff009beSToby Isaac 
669*dff009beSToby Isaac   Output Parameter:
670*dff009beSToby Isaac . isVisible - the visibility flag, `PETSC_TRUE` to print, else `PETSC_FALSE` (defaults to `PETSC_TRUE`)
671*dff009beSToby Isaac 
672*dff009beSToby Isaac   Level: developer
673*dff009beSToby Isaac 
674*dff009beSToby Isaac   Note:
675*dff009beSToby Isaac   The default log handler `PETSCLOGHANDLERDEFAULT` implements this function, but others generally do not.  You can use
676*dff009beSToby Isaac   `PetscLogStageGetVisible()` to call this function for the default log handler that is connected to the global
677*dff009beSToby Isaac   logging state (`PetscLogGetState()`).
678*dff009beSToby Isaac 
679*dff009beSToby Isaac .seealso: [](ch_profiling), `PetscLogHandlerStageSetVisible()`
680*dff009beSToby Isaac @*/
681*dff009beSToby Isaac PetscErrorCode PetscLogHandlerStageGetVisible(PetscLogHandler handler, PetscLogStage stage, PetscBool *isVisible)
682*dff009beSToby Isaac {
683*dff009beSToby Isaac   PetscFunctionBegin;
684*dff009beSToby Isaac   PetscValidHeaderSpecific(handler, PETSCLOGHANDLER_CLASSID, 1);
685*dff009beSToby Isaac   PetscTryMethod(handler, "PetscLogHandlerStageGetVisible_C", (PetscLogHandler, PetscLogStage, PetscBool *), (handler, stage, isVisible));
686*dff009beSToby Isaac   PetscFunctionReturn(PETSC_SUCCESS);
687*dff009beSToby Isaac }
688