:orphan:
# PetscLogEventRegister
Registers an event name for logging operations 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscLogEventRegister(const char name[], PetscClassId classid, PetscLogEvent *event)
```
Not Collective


## Input Parameters

- ***name   -*** The name associated with the event
- ***classid -*** The classid associated to the class for this event, obtain either with
`PetscClassIdRegister()` or use a predefined one such as `KSP_CLASSID`, `SNES_CLASSID`, the predefined ones
are only available in C code



## Output Parameter

- ***event -*** The event id for use with `PetscLogEventBegin()` and `PetscLogEventEnd()`.



## Example of Usage
```none
      PetscLogEvent USER_EVENT;
      PetscClassId classid;
      PetscLogDouble user_event_flops;
      PetscClassIdRegister("class name",&classid);
      PetscLogEventRegister("User event name",classid,&USER_EVENT);
      PetscLogEventBegin(USER_EVENT,0,0,0,0);
         [code segment to monitor]
         PetscLogFlops(user_event_flops);
      PetscLogEventEnd(USER_EVENT,0,0,0,0);
```





## Notes
PETSc automatically logs library events if the code has been
configured with --with-log (which is the default) and
-log_view or -log_all is specified.  `PetscLogEventRegister()` is
intended for logging user events to supplement this PETSc
information.

PETSc can gather data for use with the utilities Jumpshot
(part of the MPICH distribution).  If PETSc has been compiled
with flag -DPETSC_HAVE_MPE (MPE is an additional utility within
MPICH), the user can employ another command line option, -log_mpe,
to create a logfile, "mpe.log", which can be visualized
Jumpshot.

The classid is associated with each event so that classes of events
can be disabled simultaneously, such as all matrix events. The user
can either use an existing classid, such as `MAT_CLASSID`, or create
their own as shown in the example.

If an existing event with the same name exists, its event handle is
returned instead of creating a new event.


## See Also
 [](ch_profiling), `PetscLogStageRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`, `PetscLogFlops()`,
`PetscLogEventActivate()`, `PetscLogEventDeactivate()`, `PetscClassIdRegister()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/logging/plog.c.html#PetscLogEventRegister">src/sys/logging/plog.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex76.c.html">src/ksp/ksp/tutorials/ex76.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex79.c.html">src/ksp/ksp/tutorials/ex79.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex9.c.html">src/ksp/ksp/tutorials/ex9.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex5cu.cu.html">src/mat/tutorials/ex5cu.cu</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex5k.kokkos.cxx.html">src/mat/tutorials/ex5k.kokkos.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/tutorials/ex1.c.html">src/sys/classes/random/tutorials/ex1.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex3.c.html">src/sys/tutorials/ex3.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex3f.F90.html">src/sys/tutorials/ex3f.F90</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex3f90.F90.html">src/sys/tutorials/ex3f90.F90</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex10.c.html">src/vec/vec/tutorials/ex10.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex15.c.html">src/vec/vec/tutorials/ex15.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/logging/plog.c)


[Index of all Profiling routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
