Metadata-Version: 2.4
Name: lumberstack
Version: 26.4.1400
Summary: A simple abstraction of the logging package
Project-URL: Homepage, https://github.com/ghostdisco/lumberstack
Project-URL: Issues, https://github.com/ghostdisco/lumberstack/issues
Author-email: ghostdisco <pypi@ghostdisco.me>
License-File: LICENSE
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8.1
Requires-Dist: logging>=0.4.9.6
Requires-Dist: requests
Description-Content-Type: text/markdown

# Lumberstack

### Global init in \_\_main\_\_
#### Example to determine log file name
```
if helpers.am_debugging:
  log_file_name = f'{config.log_file.rstrip(".log")}_debug.log'
  if os.path.exists(log_file_name):
    os.remove(log_file_name)
else:
  log_file_name = (f'{config.log_file.rstrip(".log")}_'
                   f'{str(datetime.now() if helpers.am_debugging else datetime.utcnow()).split(".", 1)[0].replace(":", ".").replace(" ", "_")}'
                    '.log')
```

#### Only run global_init once in \_\_main\_\_
```
Lumberstack.global_init(timezone=time.localtime if helpers.am_debugging else time.gmtime, log_filename=log_file_name, log_level=config.log_level, console_output=True)
```

#### Add a custom handler during global init
```
fh = logging.FileHandler(filename='new.log')
Lumberstack.global_init(log_level=config.log_level, custom_handlers=[fh])
```

#### Update log levels of imported libraries using the logging package
```
Lumberstack.update_library_levels(libraries=['requests', 'urllib3'], log_level=config.lib_log_level)
Lumberstack.update_library_levels(libraries=['cli.azure.cli.core', 'cli.knack.cli', 'msal.authority', 'msal.application', 'msal.telemetry'], log_level=config.az_log_level)
```


### Local init for each file/module
```
logger = Lumberstack()
logger.info(f'{APP_NAME} - {APP_DESCRIPTION}')
```


### Log levels use the logging package values

* CRITICAL = 50
* FATAL = CRITICAL
* ERROR = 40
* WARNING = 30
* WARN = WARNING
* INFO = 20
* DEBUG = 10
* NOTSET = 0
