The group $U_q$ of unit quaternions is a Lie group. As a manifold it is diffeomorhic to the unit sphere in $\newcommand{\bR}{\mathbb{R}}$ $\bR^4$. (This group is infact isomorphic to the matrix Lie group $SU(2)$=unitary matrices with determinant $1$.)
There is an exponential map, defined by the usual power series, from the vector space $V$ of purely imaginary quaternions to $U_q$. This map is onto.
Note that any $v\in V$ satisfies $v^2=-1$ so
$$\exp(tv)=\cos t +(\sin t)v. $$
This exponential defines a diffeomorphism
$$ \big\{\; v\in V;\;\;\Vert v\Vert <\pi\;\big\}\ni v\to \exp(v) \in U_q\setminus\{-1\}.$$
Its inverse can be described explicitly in terms of the spherical coordinates on the unit sphere.
Note that if $q$ is a unit quaternion, and $q=\cos t+(\sin t) v$, $t\in [0,\pi)$,$\DeclareMathOperator{\re}{\mathbf{Re}}$ then $t=\arccos\big(\re (q)\big)$. Then
$$\tag{1} \log (q)=tv=\frac{\arccos(\re q)}{\sin(\arccos(\re q))}\big(q-\re q\big). $$
For a general quaternion $q=s+tv$, $s\in\bR$, $v\in V$, we have
$$\exp(s+tv)= e^s\big(\; \cos t +(\sin t)v\;\big). $$
If $q\neq -\Vert q\Vert$ one can then define a logarithm of $q$ in an obvious way
$$\log q=\log \Vert q\Vert+\log\big(\Vert q\Vert^{-1} q\big). $$
The paths $t\in \exp(tv)$$t\mapsto \exp(tv)$ are the geodesic in the unit spfere that start at the Norh pole. Use this analogy for octonions.