Nodes/ComfyUI-JDCN/LogicUtil_Log
ComfyUI Node

LogicUtil_Log

The logarithm node with a base input you should actually set

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Log
    • FLOAT
    input1
    base

    If you've ever needed to convert audio levels to dB, compress a wide brightness range into something a sampler will respect, or just scale values the way people who think in log space do, LogicUtil_Log is the node. Two float inputs in, one float out: input1 and base, computing log_base(input1).

    How it works

    The important bit is the base input, because this is where the surprises live. It's Python's math.log(x, base), so:

    • base = 10 gives you the base-10 log - the one most people mean when they say "log."
    • base = 2 is what you want for doubling/halving logic (stops, octaves, bit-depth-ish reasoning).
    • base = 2.71828... (e) is the natural log.

    There's no default baked into the source, so if you leave base untouched you're passing 0 - and math.log(x, 0) is a domain error that kills the queue. This node will not silently give you a sensible default; set the base.

    The other constraints come straight from the math, not the node. input1 must be positive - log of zero or a negative number throws. That means you can't feed this an unclamped brightness value that dips to 0, and you can't log a negative difference. People hit this constantly when they try to log a contrast delta without shifting it positive first. Feed it a string and you'll get a type error; keep it numeric.

    Where it earns its keep: scaling. Take a prompt weight or an upscale factor that spans orders of magnitude, push it through the log to flatten the curve, then re-scale - it's a cheap way to make a slider feel less insane across a huge range. It's also handy for converting ratios to human-meaningful numbers before feeding a display or text node, which is exactly the kind of plumbing the broader JDCN pack (a utility grab-bag by Daxton Caylor and Jerry Davos, with the LogicUtil family ported from aria1th's ComfyUI-LogicUtils) exists for.

    Install

    Install is the standard JDCN path: ComfyUI Manager → "Install Custom Node" → search JDCN → install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN
    cd ComfyUI-JDCN && pip install -r requirements.txt
    

    Just piexif on the requirements list, nothing to download. And if you're coming here from a workflow that uses this node, check the base value before you assume the scaling is wrong - nine times out of ten, someone set base to 10 where they wanted 2, or left it at 0 and the graph just quietly doesn't run.

    CategoryLogicUtil

    Inputs (2)

    NameTypeDefaultDescription
    input1FLOAT
    baseFLOAT

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT