# Poco

# class ArchiveStrategy

Library: Foundation
Package: Logging
Header: Poco/ArchiveStrategy.h

## Description

The ArchiveStrategy is used by FileChannel to rename a rotated log file for archiving.

Archived files can be automatically compressed, using the gzip file format.

## Inheritance

Known Derived Classes: ArchiveByNumberStrategy, ArchiveByTimestampStrategy

## Member Summary

Member Functions: archive, close, compress, exists, moveFile, open, setPurgeCallback

## Types Aliases

### PurgeCallback

using PurgeCallback = std::function < void ()>;

## Constructors

### ArchiveStrategy

ArchiveStrategy();

## Destructor

### ~ArchiveStrategy

virtual ~ArchiveStrategy();

## Member Functions

### archive

virtual LogFile * archive(
LogFile * pFile
) = 0;

Renames the given log file for archiving and creates and returns a new log file. The given LogFile object is deleted.

### close

void close();

### compress

void compress(
bool flag = true
);

Enables or disables compression of archived files.

### open

virtual LogFile * open(
LogFile * pFile
) = 0;

Open a new log file and return it.

### setPurgeCallback

void setPurgeCallback(
PurgeCallback callback
);

Sets a callback to be invoked after compression completes. Used by FileChannel to trigger purging at the right time.

### exists

bool exists(
const std::string & name
);

### moveFile

void moveFile(
const std::string & oldName,
const std::string & newName
);

## Variables

### _compressingComplete

Poco::Condition _compressingComplete;

### _compressingCount

int _compressingCount;

### _purgeCallback

PurgeCallback _purgeCallback;

### _rotateMutex

Poco::FastMutex _rotateMutex;