Section 3011 turns "the best interests of the child" from a slogan into a list. Subdivision (a) requires the court, in making that determination in a proceeding described in § 3021, to consider — among any other relevant factors consistent with § 3020 — the following.
The health, safety and welfare of the child. A history of abuse by a parent or other person seeking custody against a child they are related to or have had any caretaking relationship with however temporary, against the other parent, or against a parent, current spouse, cohabitant or dating partner of the person seeking custody; before considering such allegations the court may require independent corroboration such as reports from law enforcement, child protective services, courts, medical facilities or agencies serving victims of sexual assault or domestic violence. The nature and amount of contact with both parents, including as provided in §§ 3046 and 3100. And habitual or continual illegal use of controlled substances, habitual or continual abuse of alcohol, or habitual or continual abuse of prescribed controlled substances by either parent, again with the option of requiring independent corroboration first.
Two things about the list are easy to miss. It is not exhaustive — the court considers these "among any other factors it finds relevant" — so it is a floor rather than a ceiling. And the corroboration provisions cut both ways: they protect a parent from bare allegations, and they mean a serious allegation supported only by one person's account may not get off the ground without documents. The presumption that applies where domestic violence is found is § 3044, and the policy framework is § 3020. How these factors apply to a particular family is exactly the judgement a family lawyer is for.