The notation $\int dx/x$ is supposed to mean "the general antiderivative of $1/x$ on its domain," which is $\mathbf R - \{0\} = (-\infty,0) \cup (0,\infty)$, and the right answer should have separate additive constants on each of the intervals:
$$
\int \frac{1}{x}\,dx =
\begin{cases}
\ln x + C_1, & \text{ if } x > 0 \\
\ln|x| + C_2, & \text{ if } x < 0
\end{cases}
=
\begin{cases}
\ln|x| + C_1, & \text{ if } x > 0 \\
\ln|x| + C_2, & \text{ if } x < 0,
\end{cases}
$$
where $C_1$ and $C_2$ are constants that need not be equal. However, in practice the way that this antiderivative formula is used in standard single-variable calculus courses is to work with an antiderivative of $1/x$ on an interval inside its domain, which makes this interval a subinterval of $(0,\infty)$ or a subinterval of $(-\infty,0)$, and for this purpose only a single additive constant is needed. Thus in practice no error will be made by using the incomplete formula
$$
\int \frac{1}{x}\,dx = \ln|x| + C
$$
on $\mathbf R - \{0\}$, where $C$ is a constant. The constant is totally irrelevant to calculate $\int_a^b dx/x$ with $(a,b)$ in $(-\infty,0)$ or $(0,\infty)$, since a single antiderivative is needed on that interval, and $\ln|x|$ can serve this role.
In a similar way, since the domain of $\tan x$ in $\mathbf R$ is a union of infinitely many disjoint open intervals $I_k = (-\pi/2 + \pi k,\pi/2 + \pi k)$ where $k$ runs through the integers, the correct general antiderivative formula for $\tan x$ in a single-variable calculus course should be
$$
\int \tan x \,dx = -\ln|\cos x| + C_k \text{ for } k \in \mathbf Z,
$$
where the $C_k$'s are separate constants on each of the intervals $I_k$. These constants need not all be the same. If the only purpose to which a student in a course ever puts an antiderivative formula is to compute $\int_a^b \tan x\,dx$ where $\tan x$ is defined on $(a,b)$ (no asymptote in $(a,b)$), then the additive constant ambiguity is irrelevant and the simpler formula $-\ln|\cos x|$ can be used, or equivalently $\ln|\sec x|$.