Messaging

The biogeme.messaging module is a logger to manage the verbosity of the package.

biogeme.messaging module

Singleton managing the various levels of messages

author

Michel Bierlaire

date

Mon Jul 22 16:12:00 2019

class biogeme.messaging.bioMessage(*args, **kwargs)[source]

Bases: object

Manages the Biogeme messages

__init__(screenLevel=1)[source]

Constructor

Parameters

screenLevel (int) –

level of message that must be displayed on the screen:

  • 0: no output (default)

  • 1: warnings only

  • 2: only warnings and general information

  • 3: more verbose

  • 4: debug messages

addMessage(text, level)[source]

Add a message

Parameters
  • text (string) – text of the message.

  • level (int) –

    level of the message

    • 1: warning

    • 2: general information

    • 3: detailed information

    • 4: debug message

Note

adding a message of level 0 is meaningless, as it correspond to silentmode.

allMessages(screenLevel=None)[source]

Report all the messages up to a given level.

Parameters

screenLevel (int) –

level of message that must be reported in the file:

  • 0: no output

  • 1: warnings only

  • 2: only warnings and general information

  • 3: more verbose (default)

  • 4: debug messages

    If None (default), all messages are reported.

Returns

all messages.

Return type

str.

createLog(fileLevel=None, fileName='_biogeme')[source]

Creates a log file

Parameters
  • fileLevel (int) –

    level of message that must be reported in the file:

    • 0: no output

    • 1: warnings only

    • 2: only warnings and general information

    • 3: more verbose (default)

    • 4: debug messages

      If None (default), all messages are reported.

  • fileName (string) – name of the file (without extension). Default: ‘_biogeme’. A file called _biogeme.log will be created.

Returns

name of the file

Return type

str

debug(text)[source]

Add a debug message

Parameters

text (string) – text of the message.

detailed(text)[source]

Add a detailed message

Parameters

text (string) – text of the message.

general(text)[source]

Add a general message

Parameters

text (string) – text of the message.

lastLevel

last level used

resetMessages()[source]

Erase all messages

resume()[source]

Resume the regular operations of the logger after the use of temporarySilence

screenLevel

screen verbosity level

setDebug()[source]

Set both screen and file levels to 4

setDetailed()[source]

Set both screen and file levels to 3

setGeneral()[source]

Set both screen and file levels to 2

setScreenLevel(level)[source]

Change the level of messaging for the screen

Parameters

level (int) –

level of message that must be displayed on the screen:

  • 0: no output

  • 1: warnings only

  • 2: only warnings and general information

  • 3: more verbose

  • 4: debug messages

setSilent()[source]

Set both screen and file levels to 0

setWarning()[source]

Set both screen and file levels to 1

temporarySilence()[source]

Temporarily turns off the message, remembering the current screen level.

types

names of verbosity levels

warning(text)[source]

Add a warning

Parameters

text (string) – text of the message.