import click

from dotenv import load_dotenv, find_dotenv
from grazer.config import Config
from grazer.core import crawler


@click.command()
@click.option("--env", default=find_dotenv())
@click.option("--config")
def main(env, config):
    load_dotenv(env)
    cfg = Config(config)
    for record, link in crawler.create(cfg):
        print(record)

if __name__ == "__main__":
    main()

import click
import logging

from dotenv import load_dotenv, find_dotenv
from grazer.config import Config
from grazer.core import crawler


@click.command()
@click.option("--env", default=find_dotenv())
@click.option("--config")
@click.option("--log_level", default="INFO")
def main(env, config, log_level):
    logging.basicConfig(level=getattr(logging, log_level))
    load_dotenv(env)
    cfg = Config(config)
    for record, link in crawler.create(cfg):
        print(record)

if __name__ == "__main__":
    main()

Allow to config log level
Allow to config log level

  import click
+ import logging
  
  from dotenv import load_dotenv, find_dotenv
  from grazer.config import Config
  from grazer.core import crawler
  
  
  @click.command()
  @click.option("--env", default=find_dotenv())
  @click.option("--config")
+ @click.option("--log_level", default="INFO")
- def main(env, config):
+ def main(env, config, log_level):
+     logging.basicConfig(level=getattr(logging, log_level))
      load_dotenv(env)
      cfg = Config(config)
      for record, link in crawler.create(cfg):
          print(record)
  
  if __name__ == "__main__":
      main()
  
Allow to config log level
## Code Before:
import click

from dotenv import load_dotenv, find_dotenv
from grazer.config import Config
from grazer.core import crawler


@click.command()
@click.option("--env", default=find_dotenv())
@click.option("--config")
def main(env, config):
    load_dotenv(env)
    cfg = Config(config)
    for record, link in crawler.create(cfg):
        print(record)

if __name__ == "__main__":
    main()

## Instruction:
Allow to config log level
## Code After:
import click
import logging

from dotenv import load_dotenv, find_dotenv
from grazer.config import Config
from grazer.core import crawler


@click.command()
@click.option("--env", default=find_dotenv())
@click.option("--config")
@click.option("--log_level", default="INFO")
def main(env, config, log_level):
    logging.basicConfig(level=getattr(logging, log_level))
    load_dotenv(env)
    cfg = Config(config)
    for record, link in crawler.create(cfg):
        print(record)

if __name__ == "__main__":
    main()
