CPLog
Game logging interface.
As CosPlay games are terminal-based they require a different approach to logging since CosPlay cannot use the standard terminal output (it will conflict the game rendering). All the log that goes through this interface always ends up in two places:
- Built-in GUI-based log viewer that can be opened in any game by pressing
Ctrl-l
at any time. - In
*.txt
log files under${USER_HOME}/.cosplay/log/xxx
directory, wherexxx
is the name of the game.
The instance of this logger is available to any scene object via CPSceneObjectContext.getLog. You can also get a root logger at any time outside the frame update pass via CPEngine.rootLog method. Note that additionally to the standard familiar logging APIs this interface supports log throttling that's important in games since most of the game logic gets "touched" up to 30 times a second and log throttling is essential for not overflowing logging.
Underneath the implementation is using latest Log4j2 library. You can
supply your own log4j2.xml
file on the classpath of your game. Here's the default Log4j2 configuration:
<Configuration status="INFO" strict="true">
<Appenders>
<RollingFile
name="file"
fileName="${sys:user.home}/.cosplay/log/${sys:COSPLAY_GAME_ID}/log.txt"
filePattern="${sys:user.home}/.cosplay/log/${sys:COSPLAY_GAME_ID}/$${date:yyyy-MM}/log-%d{MM-dd-yyyy}-%i.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="file"/>
</Root>
</Loggers>
</Configuration>
Attributes
- See also:
- Source:
- CPLog.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any