Logfile Module

Target of this module is supply logging features to user and to dbrm itself.

Variables

Variable Description
LOGFILE Contains path of logfile to use. If this variable is not set call to write command do nothing.

Commands

logfile version

Show version of logfile module.

  $# dbrm logfile version 
  Version: 0.1.0

logfile info

With info command is possible retrieve status of the logfile module and what is current logfile use for store logging string.

  $# dbrm logfile info
  ===========================================================================
  Module [logfile]:
  ---------------------------------------------------------------------------
  Logfile = ./dbm.log
  Status  = 1
  ---------------------------------------------------------------------------
  ===========================================================================

logfile reset

Remove current logfile.

Exit Values:

  • 1: On error or if logfile module is not enabled.
  • 0: On success
  $# dbrm logfile reset
  Are you sure to remove file ./dbm.log ? [y/N]y
  File ./dbm.log removed correctly.

logfile write

This command permit from a shell logging message to configured logfile. Every message contains a date and a line as seperator.

Exit Values:

  • 1: On error
  • 0: On success
  $# dbrm logfile write "INFO - Test logging"
  $# cat ./dbm.log
  ------------------------------------------------------
  20170422-18:58:34 - INFO - Test logging
  ------------------------------------------------------

API

_logfile_init

Method called when module logfile is initialized. Check if it is defined LOGFILE variable and check if file is writable. If LOGFILE variable is not set then logfile module is automatically disabled.

(Show/Hide)

_logfile_write

Internal function that write input message to logfile.

Parameters:

  • $1: message to write on logfile

Returns:

  • 1: On error
  • 0: On success
   # Write message to logfile
   _logfile_write "My message to write on LOGFILE!!!"
(Show/Hide)