Hope below example with shopt -s expand_aliases and alias could help:
try.sh
#! /usr/bin/env bash
shopt -s expand_aliases
# =============================================================
# Define the logger
# =============================================================
alias logger='logger_function [${BASH_SOURCE##*/}] [$FUNCNAME] [$LINENO] '
logger_function()
{
echo $@
}
# =============================================================
# Use the logger
# =============================================================
my_function()
{
logger "hello world!"
}
my_function
Test result in: GNU bash, version 3.2.57(1)-release
$ ./try.sh
[try.sh] [my_function] [20] hello world!
Considering the question is emphasizing on: line number, so in this example, the exactly same input and output of the question are not used.
But to make it more informative, the logging utility definition is added with:
$BASH_SOURCE
$FUNCNAME
$LINENO
So, it can print the file name, function name and line number.
Regarding to alias usage here, it looks like but isn't really comparable to a C macro according to: https://tldp.org/LDP/abs/html/aliases.html