{
/** Severity of the entry, shown as a badge on the left. */
state: LogState;
/** Moment the entry occurred, rendered as `hh:mm:ss:ms`. */
timeStamp: Date;
/** Optional origin of the entry, rendered next to the time. */
source?: ReactNode;
/** Whether to render a small "ACK" box on the right side. */
ack?: boolean;
/** Description of the entry. */
children: ReactNode;
}
/**
* Single entry of a {@link Log}: a severity badge, a timestamp, an optional
* source, a description, and an optional acknowledgement indicator.
*
* @example
* ```tsx
*
* Cycle aborted
*
* ```
*/
function LogItem({ className, state, timeStamp, source, ack, children, ...rest }: LogItemProps) {
return (
{badgeGlyph[state]}
{formatLogTimestamp(timeStamp)}
{source != null && {source}}
{children}
{ack && ACK}
);
}
/**
* Fullwidth log of {@link Log.Item}s, each showing a severity badge, a
* timestamp, an optional source, a description, and an optional
* acknowledgement indicator.
*
* @example
* ```tsx
*
*
* Safety guard opened during motion
*
*
* Cycle aborted
*
*
* ```
*/
export function Log({ className, title, withBorder = true, children, ...rest }: LogProps) {
return (
{title &&
{title}
}
{children}
);
}
Log.Item = LogItem;