Documents / @faasjs/logger / Logger
Class: Logger
Logger Class
Support env:
- FaasLog: debug, info, warn, error (default: debug)
- FaasLogSize: 1000 (default: 1000)
- FaasLogMode: plain, pretty (default: pretty)
Example
const logger = new Logger()
logger.debug('debug message')
logger.info('info message')
logger.warn('warn message')
logger.error('error message')
logger.time('timer name')
logger.timeEnd('timer name', 'message') // => 'message +1ms'
Constructors
new Logger()
new Logger(
label
?):Logger
Parameters
• label?: string
{string} Prefix label
Returns
Methods
colorfy()
colorfy(
color
,message
):string
Parameters
• color: number
{number} color code
• message: string
{string} message
Returns
string
debug()
debug(
message
, ...args
):Logger
Parameters
• message: string
{string} message
• ...args: any
[]
{...any=} arguments
Returns
error()
error(
message
, ...args
):Logger
Parameters
• message: string
| Error
{any} message or Error object
• ...args: any
[]
{...any=} arguments
Returns
info()
info(
message
, ...args
):Logger
Parameters
• message: string
{string} message
• ...args: any
[]
{...any=} arguments
Returns
raw()
raw(
message
, ...args
):Logger
Parameters
• message: string
{string} message
• ...args: any
[]
{...any=} arguments
Returns
time()
time(
key
,level
):Logger
Parameters
• key: string
{string} timer's label
• level: Level
= 'debug'
[string=debug] 日志级别,支持 debug、info、warn、error
Returns
timeEnd()
timeEnd(
key
,message
, ...args
):Logger
Parameters
• key: string
{string} timer's label
• message: string
{string} message
• ...args: any
[]
{...any=} arguments
Returns
warn()
warn(
message
, ...args
):Logger
Parameters
• message: string
{string} message
• ...args: any
[]
{...any=} arguments
Returns
Properties
colorfyOutput
colorfyOutput:
boolean
=true
label?
optional
label:string
level
level:
number
=0
silent
silent:
boolean
=false
size
size:
number
=1000
stderr()
stderr: (
text
) =>void
Parameters
• text: string
Returns
void
stdout()
stdout: (
text
) =>void
Parameters
• text: string
Returns
void