class_docstr: A Reporter object that abstracts various logging capabilities
  
  To set-up a Reporter, simply perform the following tasks:
  
  .. code-block:: python
  
      from pyswarms.utils import Reporter
  
      rep = Reporter()
      rep.log("Here's my message", lvl=logging.INFO)
  
  This will set-up a reporter with a default configuration that
  logs to a file, `report.log`, on the current working directory.
  You can change the log path by passing a string to the `log_path`
  parameter:
  
  .. code-block:: python
  
      from pyswarms.utils import Reporter
  
      rep = Reporter(log_path="/path/to/log/file.log")
      rep.log("Here's my message", lvl=logging.INFO)
  
  If you are working on a module and you have an existing logger,
  you can pass that logger instance during initialization:
  
  .. code-block:: python
  
      # mymodule.py
      from pyswarms.utils import Reporter
  
      # An existing logger in a module
      logger = logging.getLogger(__name__)
      rep = Reporter(logger=logger)
  
  Lastly, if you have your own logger configuration (YAML file),
  then simply pass that to the `config_path` parameter. This
  overrides the default configuration (including `log_path`):
  
  .. code-block:: python
  
      from pyswarms.utils import Reporter
  
      rep = Reporter(config_path="/path/to/config/file.yml")
      rep.log("Here's my message", lvl=logging.INFO)
class_docstr_tok: ["A","Reporter","object","that","abstracts","various","logging","capabilities","To","set-up","a","Reporter",",","simply","perform","the","following","tasks",":","..","code-block",":",":","python","from","pyswarms.utils","import","Reporter","rep","=","Reporter","(",")","rep.log","(","``","Here","'s","my","message","''",",","lvl=logging.INFO",")","This","will","set-up","a","reporter","with","a","default","configuration","that","logs","to","a","file",",","`","report.log","`",",","on","the","current","working","directory",".","You","can","change","the","log","path","by","passing","a","string","to","the","`","log_path","`","parameter",":","..","code-block",":",":","python","from","pyswarms.utils","import","Reporter","rep","=","Reporter","(","log_path=","''","\/path\/to\/log\/file.log","''",")","rep.log","(","``","Here","'s","my","message","''",",","lvl=logging.INFO",")","If","you","are","working","on","a","module","and","you","have","an","existing","logger",",","you","can","pass","that","logger","instance","during","initialization",":","..","code-block",":",":","python","#","mymodule.py","from","pyswarms.utils","import","Reporter","#","An","existing","logger","in","a","module","logger","=","logging.getLogger","(","__name__",")","rep","=","Reporter","(","logger=logger",")","Lastly",",","if","you","have","your","own","logger","configuration","(","YAML","file",")",",","then","simply","pass","that","to","the","`","config_path","`","parameter",".","This","overrides","the","default","configuration","(","including","`","log_path","`",")",":","..","code-block",":",":","python","from","pyswarms.utils","import","Reporter","rep","=","Reporter","(","config_path=","''","\/path\/to\/config\/file.yml","''",")","rep.log","(","``","Here","'s","my","message","''",",","lvl=logging.INFO",")"]
docstr: Initialize the reporter
  
  Attributes
  ----------
  log_path : str, optional
      Sets the default log path (overriden when :code:`path` is given to
      :code:`_setup_logger()`)
  config_path : str, optional
      Sets the configuration path for custom loggers
  logger : logging.Logger, optional
      The logger object. By default, it creates a new :code:`Logger`
      instance
  printer : pprint.PrettyPrinter, optional
      A printer object. By default, it creates a :code:`PrettyPrinter`
      instance with default values
docstr_tok: ["Initialize","the","reporter","Attributes","--","--","--","--","--","log_path",":","str",",","optional","Sets","the","default","log","path","(","overriden","when",":","code",":","`","path","`","is","given","to",":","code",":","`","_setup_logger","(",")","`",")","config_path",":","str",",","optional","Sets","the","configuration","path","for","custom","loggers","logger",":","logging.Logger",",","optional","The","logger","object",".","By","default",",","it","creates","a","new",":","code",":","`","Logger","`","instance","printer",":","pprint.PrettyPrinter",",","optional","A","printer","object",".","By","default",",","it","creates","a",":","code",":","`","PrettyPrinter","`","instance","with","default","values"]
code: def __init__(
      self, log_path=None, config_path=None, logger=None, printer=None
  ):
      """Initialize the reporter
  
      Attributes
      ----------
      log_path : str, optional
          Sets the default log path (overriden when :code:`path` is given to
          :code:`_setup_logger()`)
      config_path : str, optional
          Sets the configuration path for custom loggers
      logger : logging.Logger, optional
          The logger object. By default, it creates a new :code:`Logger`
          instance
      printer : pprint.PrettyPrinter, optional
          A printer object. By default, it creates a :code:`PrettyPrinter`
          instance with default values
      """
      self.logger = logger or logging.getLogger(__name__)
      self.printer = printer or pprint.PrettyPrinter()
      self.log_path = log_path or (os.getcwd() + "/report.log")
      self._bar_fmt = "{l_bar}{bar}|{n_fmt}/{total_fmt}{postfix}"
      self._env_key = "LOG_CFG"
      self._default_config = {
          "version": 1,
          "disable_existing_loggers": False,
          "formatters": {
              "standard": {
                  "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
              }
          },
          "handlers": {
              "default": {
                  "level": "INFO",
                  "class": "logging.StreamHandler",
                  "formatter": "standard",
              },
              "file_default": {
                  "level": "INFO",
                  "formatter": "standard",
                  "class": "logging.handlers.RotatingFileHandler",
                  "filename": self.log_path,
                  "encoding": "utf8",
                  "maxBytes": 10485760,
                  "backupCount": 20,
              },
          },
          "loggers": {
              "": {
                  "handlers": ["default", "file_default"],
                  "level": "INFO",
                  "propagate": True,
              }
          },
      }
      self._setup_logger(config_path)
  
file_path: pyswarms/pyswarms/utils/reporter/reporter.py
imports: import logging
  import logging.config
  import os
  import pprint
  import yaml
  from tqdm import trange
label_desc: Use image node_id 1 to create a new Reporter object from inherited base classes: object with example: obj = Reporter(log_path, config_path, logger, printer)