Switch logging on/off. val should be ONLY a boolean.
(self,val)
| 127 | self.log_active = True |
| 128 | |
| 129 | def switch_log(self,val): |
| 130 | """Switch logging on/off. val should be ONLY a boolean.""" |
| 131 | |
| 132 | if val not in [False,True,0,1]: |
| 133 | raise ValueError('Call switch_log ONLY with a boolean argument, ' |
| 134 | 'not with: %s' % val) |
| 135 | |
| 136 | label = {0:'OFF',1:'ON',False:'OFF',True:'ON'} |
| 137 | |
| 138 | if self.logfile is None: |
| 139 | print(""" |
| 140 | Logging hasn't been started yet (use logstart for that). |
| 141 | |
| 142 | %logon/%logoff are for temporarily starting and stopping logging for a logfile |
| 143 | which already exists. But you must first start the logging process with |
| 144 | %logstart (optionally giving a logfile name).""") |
| 145 | |
| 146 | else: |
| 147 | if self.log_active == val: |
| 148 | print('Logging is already',label[val]) |
| 149 | else: |
| 150 | print('Switching logging',label[val]) |
| 151 | self.log_active = not self.log_active |
| 152 | self.log_active_out = self.log_active |
| 153 | |
| 154 | def logstate(self): |
| 155 | """Print a status message about the logger.""" |