def buildLog(self, command, tokens, index):
        """create log in current logger

           log name  [to fileName] [as (text, binary)] [on rule]
           rule: (once, never, always, update, change)
           default fileName is log's name
           default type is text
           default rule  is update

           for manual logging use tally command with rule once or never


           log autopilot (text, binary, console) to './logs/' on (never, once, update, change, always)
        """
        if not self.currentLogger:
            msg = "Error building %s. No current logger." % (command,)
            raise excepting.ParseError(msg, tokens, index)

        if not self.currentStore:
            msg = "Error building %s. No current store." % (command,)
            raise excepting.ParseError(msg, tokens, index)

        try:
            kind = 'text'
            fileName = ''
            rule = NEVER

            name = tokens[index]
            index +=1


            while index < len(tokens): #options
                connective = tokens[index]
                index += 1

                if connective == 'as':
                    kind = tokens[index]
                    index +=1

                    if kind not in ['text', 'binary']:
                        msg = "Error building %s. Bad kind = %s." %\
                              (command, kind)
                        raise excepting.ParseError(msg, tokens, index)

                elif connective == 'to':
                    fileName = tokens[index]
                    index +=1

                elif connective == 'on':
                    rule = tokens[index].capitalize()
                    index +=1

                    if rule not in LogRuleValues:
                        msg = "Error building %s. Bad rule = %s." %\
                              (command, rule)
                        raise excepting.ParseError(msg, tokens, index)

                    rule = LogRuleValues[rule]

                else:
                    msg = "Error building %s. Bad connective got %s." %\
                          (command, connective)
                    raise excepting.ParseError(msg, tokens, index)

            if name in logging.Log.Names:
                msg = "Error building %s. Log %s already exists." %\
                      (command, name)
                raise excepting.ParseError(msg, tokens, index)

            log = logging.Log(name = name, store = self.currentStore, kind = kind,
                              fileName = fileName, rule = rule)
            self.currentLogger.addLog(log)
            self.currentLog = log

            console.profuse("     Created log named {0} kind {1} file {2} rule {3}\n".format(
                name, kind, fileName, LogRuleNames[rule]))

        except __HOLE__:
            msg = "Error building %s. Not enough tokens." % (command,)
            raise excepting.ParseError(msg, tokens, index)

        if index != len(tokens):
            msg = "Error building %s. Unused tokens." % (command, )
            raise excepting.ParseError(msg, tokens, index)

        return True
dataset/ETHPy150Open ioflo/ioflo/ioflo/base/building.py/Builder.buildLog